Skip to content

Commit

Permalink
Add build.cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
vicancy committed Jul 1, 2015
1 parent 163140d commit c2683e9
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 145 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/**/*.sln.ide/
/TestResults/
/.vs/
.NuGet/
artifacts/
target/

###############
# temp file #
Expand Down
9 changes: 8 additions & 1 deletion All.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22921.0
VisualStudioVersion = 14.0.22919.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "docfx", "src\docfx\docfx.csproj", "{AB97BEDF-D207-42E9-A56F-C9DD395BFCDD}"
EndProject
Expand Down Expand Up @@ -38,6 +38,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{004952
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DocAsCode.EntityModel.Tests", "test\Microsoft.DocAsCode.EntityModel.Tests\Microsoft.DocAsCode.EntityModel.Tests.csproj", "{EFAA7A53-D047-422E-A3FB-ECC834944CE6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{5AED685E-6E0F-451D-AD5E-F88B0BE74ACD}"
ProjectSection(SolutionItems) = preProject
build.cmd = build.cmd
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{47192798-670B-4F7C-A48B-CF8A695E6C45}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
11 changes: 11 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="automatic" value="False" />
</packageRestore>
<packageSources>
<add key="TOBEDEPRECATED" value="\\cpvsbuild\drops\Roslyn\Main-Signed-Release\20150605.2\NuGet\Shipping\PerBuildPreRelease" />
<add key="AspNetvNext" value="https://www.myget.org/F/aspnetvnext/" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
</configuration>
91 changes: 90 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1 +1,90 @@
ECHO TO BE ADDED
@ECHO OFF
CD %~dp0

SETLOCAL

IF NOT DEFINED VisualStudioVersion (
IF DEFINED VS140COMNTOOLS (
CALL "%VS140COMNTOOLS%\VsDevCmd.bat"
GOTO :EnvSet
)

ECHO Error: build.cmd requires Visual Studio 2015.
SET ERRORLEVEL=1
GOTO :Exit
)

:EnvSet
SET DNU_EXE=dnu
SET _buildproj=%~dp0All.sln

:: Check if DNU exists globally
WHERE %DNU_EXE%

IF NOT '%ERRORLEVEL%'=='0' (
ECHO ERROR: build.cmd requires dnu installed gloablly.
GOTO :Exit
)

:: Restore packages for .csproj projects

CALL :RestorePackage

:: Log build command line
SET _buildlog=%~dp0msbuild.log
SET _buildprefix=echo
SET _buildpostfix=^> "%_buildlog%"
CALL :Build %*

:: Build
SET _buildprefix=
SET _buildpostfix=
CALL :Build %*

GOTO :AfterBuild

:AfterBuild

:: Pull the build summary from the log file
ECHO.
ECHO === BUILD RESULT ===
findstr /ir /c:".*Warning(s)" /c:".*Error(s)" /c:"Time Elapsed.*" "%_buildlog%"

:: Pull xunit test result from the log file
ECHO.
ECHO === TEST EXECUTION SUMMARY ===
findstr /ir /c:"Total:.*Failed.*Skipped.*Time.*" "%_buildlog%"

GOTO :Exit

:Build
%_buildprefix% msbuild "%_buildproj%" /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%_buildlog%";Append %* %_buildpostfix%

:RestorePackage
:: Restore inside each subfolder
FOR /D %%x IN ("src","docs","test") DO (
PUSHD %%x
CMD /C %DNU_EXE% restore --parallel
POPD
)

SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe

IF EXIST %CACHED_NUGET% GOTO COPYNUGET
ECHO Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet MD %LocalAppData%\NuGet
@powershell -NoProfile -ExecutionPolicy UnRestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'"

:COPYNUGET
IF EXIST .NuGet\NuGet.exe GOTO RESTORE
MD .NuGet
COPY %CACHED_NUGET% .NuGet\NuGet.exe

:RESTORE
:: Currently has corpnet dependency
.NuGet\NuGet.exe restore "%_buildproj%"

:Exit
ECHO.
ECHO Exit Code = %ERRORLEVEL%
EXIT /B %ERRORLEVEL%
6 changes: 4 additions & 2 deletions src/Shared/base.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
<!-- Note: get rid of vshost.exe since we don't gain much benefits -->
<UseVSHostingProcess>false</UseVSHostingProcess>
<WarningLevel>4</WarningLevel>
<OutputPath Condition="'$(OutputPath)'==''">bin\$(Configuration)\</OutputPath>
<OutputPath Condition="'$(OutputPath)'==''">$(MSBuildThisFileDirectory)..\..\target\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
<TaskToolPath>$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</TaskToolPath>
<TaskToolPath Condition="'$(MSBuildToolsVersion)' == '14.0'">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</TaskToolPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand All @@ -35,7 +37,7 @@
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>

<UsingTask TaskName="GenerateVersionCSFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<UsingTask TaskName="GenerateVersionCSFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(TaskToolPath)">
<ParameterGroup>
<GitVersion ParameterType="System.String" Required="true" />
<VersionCSPath ParameterType="System.String" Required="true" />
Expand Down
26 changes: 1 addition & 25 deletions src/Shared/xproj.base.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup>
<!-- Cautious: trailing forward slash and backward slash must be eliminated -->
<BRANCH_ROOT Condition=" '$(BRANCH_ROOT)' == '' ">$([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.FullName)</BRANCH_ROOT>
<GITPATH Condition=" '$(GIT_ROOT)' == '' ">$(MSBuildProgramFiles32)/Git/cmd/git.exe</GITPATH>
<ProjectJsonFilePath>$(MSBuildProjectDirectory)/project.json</ProjectJsonFilePath>
<GlobalReferencePath>$(MSBuildProgramFiles32)/Reference Assemblies/Microsoft/Framework/.NETFramework/$(TargetFrameworkVersion)</GlobalReferencePath>
<PowerShellExe Condition=" '$(PowerShellExe)'=='' ">%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe</PowerShellExe>
<ScriptPath Condition="'$(ScriptPath)'=='' ">$(MSBuildThisFileDirectory)/XprojUpdateVersion.ps1</ScriptPath>
<OutputPath Condition="'$(OutputPath)'=='' ">$(MSBuildThisFileDirectory)..\..\artifacts\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<UsingTask TaskName="OverwriteXpojVersion" AssemblyFile="XprojVersionCustomTask.dll" />

<!-- Version information is mandatory -->
<Target Name="GenerateVersionInfo" BeforeTargets="PrepareForBuild">
<Exec Command="&quot;$(GITPATH)&quot; describe" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output PropertyName="OutputConsoleValue" TaskParameter="ConsoleOutput"/>
<Output PropertyName="ExecExitCode" TaskParameter="ExitCode"/>
</Exec>
<Exec Command="$(PowerShellExe) -NonInteractive -ExecutionPolicy RemoteSigned -Command &quot; &amp; {&amp;&apos;$(ScriptPath)&apos; &apos;$(OutputConsoleValue)&apos; &apos;$(ProjectJsonFilePath)&apos; }&quot;" Condition="$(ExecExitCode) == '0'" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output PropertyName="ExecExitCode" TaskParameter="ExitCode"/>
<Output PropertyName="OutputMessage" TaskParameter="ConsoleOutput"/>
</Exec>
<Warning Text="$(OutputMessage)" Condition="$(ExecExitCode) != '0'" />
</Target>

<ItemGroup>
<Compile Include="$(BRANCH_ROOT)\TEMP\version.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\xunit.runner.visualstudio.2.1.0-beta2-build1055\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.1.0-beta2-build1055\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\..\packages\xunit.core.2.1.0-beta2-build2981\build\Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.1.0-beta2-build2981\build\Xamarin.iOS\xunit.core.props')" />
<Import Project="..\..\packages\xunit.core.2.1.0-beta2-build2981\build\portable-net45+dnxcore50+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.1.0-beta2-build2981\build\portable-net45+dnxcore50+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
<Import Project="..\Shared\base.props" />
<Import Project="..\Shared\test.base.props" />
<PropertyGroup>
<ProjectGuid>{EFAA7A53-D047-422E-A3FB-ECC834944CE6}</ProjectGuid>
<OutputType>Library</OutputType>
Expand Down Expand Up @@ -120,19 +117,4 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\xunit.core.2.1.0-beta2-build2981\build\portable-net45+dnxcore50+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.1.0-beta2-build2981\build\portable-net45+dnxcore50+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
<Error Condition="!Exists('..\..\packages\xunit.core.2.1.0-beta2-build2981\build\Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.1.0-beta2-build2981\build\Xamarin.iOS\xunit.core.props'))" />
<Error Condition="!Exists('..\..\packages\xunit.runner.visualstudio.2.1.0-beta2-build1055\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.visualstudio.2.1.0-beta2-build1055\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
1 change: 1 addition & 0 deletions test/Microsoft.DocAsCode.EntityModel.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<package id="xunit.core" version="2.1.0-beta2-build2981" targetFramework="net4"/>
<package id="xunit.extensibility.core" version="2.1.0-beta2-build2981" targetFramework="net4"/>
<package id="xunit.runner.visualstudio" version="2.1.0-beta2-build1055" targetFramework="net452"/>
<package id="xunit.runner.msbuild" version="2.1.0-beta3-build3029" targetFramework="net452" userInstalled="true" />
</packages>
97 changes: 0 additions & 97 deletions test/Shared/base.props

This file was deleted.

Loading

0 comments on commit c2683e9

Please sign in to comment.