Skip to content

Commit

Permalink
Migrate All.sln to .NET Core
Browse files Browse the repository at this point in the history
  • Loading branch information
qinezh committed Sep 13, 2016
1 parent 46cc480 commit 2c082bc
Show file tree
Hide file tree
Showing 15 changed files with 334 additions and 1,137 deletions.
375 changes: 12 additions & 363 deletions All.sln

Large diffs are not rendered by default.

610 changes: 0 additions & 610 deletions NonNETCore.sln

This file was deleted.

169 changes: 47 additions & 122 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,38 @@ if /I [%1]==[raw] (
SET SkipTemplate=true
GOTO Next
)

if /I [%1]==[template] (
SET UpdateTemplate=%1
GOTO Next
)
if /I [%1]==[nonnetcore] (
SET OnlyNonNetCore=true
GOTO Next
)
REM TODO: remove it in next sprint
if /I [%1]==[nondnx] (
SET OnlyNonNetCore=true
GOTO Next
)

:Next
SHIFT /1
GOTO Loop

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

ECHO Error: build.cmd requires Visual Studio 2015.
SET ERRORLEVEL=1
:: Check if dotnet cli exists globally
WHERE dotnet >NUL
IF NOT [!ERRORLEVEL!]==[0] (
ECHO ERROR: dotnet CLI is not successfully configured.
ECHO ERROR: Please follow https://www.microsoft.com/net/core to install .NET Core.
GOTO Exit
)
:: Check if nuget.exe exists globally
WHERE nuget >NUL
IF NOT [!ERRORLEVEL!]==[0] (
ECHO ERROR: nuget is not successfully configured.
ECHO ERROR: Please follow https://www.nuget.org/ to install nuget.exe and add it to the path.
GOTO Exit
)

:EnvSet
:: Set environment variable
SET BuildProj=%~dp0All.sln
IF [%Configuration%]==[] (
SET Configuration=Release
)

IF /I [%Environment%]==[PROD] (
ECHO Updating version for PROD environment
CALL UpdateVersion.cmd
Expand All @@ -70,17 +67,15 @@ IF /I [%Environment%]==[PROD] (
GOTO Exit
)
)

IF /I [%UpdateTemplate%]==[template] (
ECHO Updating template
CALL UpdateTemplate.cmd
IF NOT [!ERRORLEVEL!]==[0] (
ECHO ERROR: Error occurs when updating template
)
CALL :UpdateTemplate
GOTO Exit
)

IF /I [%SkipTemplate%]==[true] (
ECHO Skip updating template
GOTO CheckIfOnlyBuildNonDnx
GOTO RestorePackage
)

:: Update template before build
Expand All @@ -92,120 +87,50 @@ IF NOT [!ERRORLEVEL!]==[0] (
GOTO Exit
)

:CheckIfOnlyBuildNonDnx
IF /I [%OnlyNonNetCore%]==[true] (
ECHO Only build NonNETCore.sln
SET BuildProj=%~dp0NonNETCore.sln
CALL :RestoreNormalPackage
GOTO SetBuildLog
)

:: Check if dotnet cli exists globally
:CheckDotnetCli
WHERE dotnet >NUL
IF NOT [!ERRORLEVEL!]==[0] (
ECHO ERROR: dotnet CLI is not successfully configured.
ECHO ERROR: Please follow https://www.microsoft.com/net/core to install .NET Core.
GOTO Exit
)

:: Restore packages for .csproj projects

CALL :RestorePackage

:: Log build command line
:SetBuildLog
SET BuildLog=%~dp0msbuild.log
SET BuildPrefix=echo
SET BuildPostfix=^> "%BuildLog%"

CALL :Build %*

:: Build
SET BuildPrefix=
SET BuildPostfix=
CALL :Build %*

IF NOT [!ERRORLEVEL!]==[0] (
GOTO AfterBuild
:RestorePackage
FOR /D %%x IN ("src", "test") DO (
PUSHD %%x
dotnet restore
POPD
)

POPD

:AfterBuild
CALL :RunAllTest
CALL :GenerateArtifacts

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

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

ECHO Exit Code: %BuildErrorLevel%
SET ERRORLEVEL=%BuildErrorLevel%

GOTO Exit

:Build
REM remove for dotnet cli bug https://github.com/dotnet/cli/issues/2871
REM dotnet build src\docfx -c %Configuration% -o target\%Configuration%\docfx.cli -f net452
dotnet build src\docfx -c %Configuration% -f net452
XCOPY /ey src\docfx\bin\%Configuration%\net452\win7-x64\** target\%Configuration%\docfx.cli\
%BuildPrefix% msbuild "%BuildProj%" /p:Configuration=%Configuration% /nologo /maxcpucount:1 /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=d;LogFile="%BuildLog%"; %BuildPostfix%
SET BuildErrorLevel=%ERRORLEVEL%
EXIT /B %ERRORLEVEL%

:GenerateArtifacts
ECHO pack nuget package
:BuildProject
ECHO Building project
FOR /f %%g IN ('DIR /b "src"') DO (
CMD /C dotnet pack src\%%g -c Release -o artifacts\Release
dotnet build src\%%g -c %Configuration% -f net452
XCOPY /ey src\%%g\bin\%Configuration%\net452\win7-x64\** target\%Configuration%\%%g\
)

:RunAllTest
ECHO run all test
:RunUnitTests
ECHO Run all unit tests
FOR /f %%g IN ('DIR /b "test"') DO (
IF NOT %%g==Shared (
IF NOT %%g==docfx.E2E.Tests (
CMD /C dotnet test test\%%g
dotnet test test\%%g
)
)
)

:RestorePackage

:RestoreNormalPackage
:: Currently version 3.3 is not compatible with our build, force to use v2.8.6
SET CachedNuget=%LocalAppData%\NuGet\v2.8.6\NuGet.exe
IF EXIST "%CachedNuget%" GOTO Restore
ECHO Downloading NuGet.exe v2.8.6...
IF NOT EXIST "%LocalAppData%\NuGet\v2.8.6" MD "%LocalAppData%\NuGet\v2.8.6"
powershell -NoProfile -ExecutionPolicy UnRestricted -Command "$ProgressPreference = 'SilentlyContinue'; [Net.WebRequest]::DefaultWebProxy.Credentials = [Net.CredentialCache]::DefaultCredentials; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/v2.8.6/nuget.exe' -OutFile '%CachedNuget%'"

IF NOT [!ERRORLEVEL!]==[0] (
ECHO ERROR: Failed downloading NuGet.exe
GOTO Exit
)

:Restore
%CachedNuget% restore "%BuildProj%"
IF NOT [!ERRORLEVEL!]==[0] (
ECHO ERROR: Error when restoring packages for %BuildProj%
:GenerateArtifacts
ECHO pack projct nuget package
FOR /f %%g IN ('DIR /b "src"') DO (
dotnet pack src\%%g -c %Configuration% -o artifacts\%Configuration%
)

:RestoreDnuPackage
FOR /D %%x IN ("src", "test") DO (
PUSHD %%x
CMD /C dotnet restore
POPD
ECHO pack docfx.conosle
ECHO XCOPY /ey target\%Configuration%\docfx\*.dll src\nuspec\docfx.console\tools\
XCOPY /ey target\%Configuration%\docfx\*.dll src\nuspec\docfx.console\tools\
XCOPY /ey target\%Configuration%\docfx\*.exe src\nuspec\docfx.console\tools\
XCOPY /ey target\%Configuration%\docfx\*.exe.config src\nuspec\docfx.console\tools\
SET versionFile=TEMP/version.txt
IF EXIST %versionFile% (
SET /p version=<TEMP/version.txt
) ELSE (
SET version=1.0.0
)
nuget pack src\nuspec\docfx.console\docfx.console.nuspec -Version %version% -OutputDirectory artifacts\%Configuration%

:Exit
POPD
ECHO.

EXIT /B %ERRORLEVEL%
EXIT /B %ERRORLEVEL%
54 changes: 54 additions & 0 deletions src/nuspec/docfx.console/build/docfx.console.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildDocToolPath>$(MSBuildThisFileDirectory)..\tools\docfx.exe</BuildDocToolPath>
<DocfxConfigFile Condition=" '$(DocfxConfigFile)' == '' ">$(MSBuildProjectDirectory)/docfx.json</DocfxConfigFile>
<PreviewPort Condition=" '$(PreviewPort)' == '' ">8002</PreviewPort>
<IsServing Condition="'$(IsServing)'==''">False</IsServing>
<PreviewOutputFolder Condition=" '$(PreviewOutputFolder)' == '' ">$(OutputFolder)/_site</PreviewOutputFolder>
<LogFile Condition=" '$(LogFile)' == '' ">log.txt</LogFile>
<LogLevel Condition=" '$(LogLevel)' == '' ">Verbose</LogLevel>

<!-- Website project's output directory is current folder, disable it as a temp workaround until a better way is found-->
<CopyToOutput>False</CopyToOutput>
<RebuildDoc Condition=" '$(RebuildDoc)' == '' ">False</RebuildDoc>
</PropertyGroup>
<Target Name="DocRebuild">
<CallTarget Targets="DocClean"/>
<CallTarget Targets="DocBuild"/>
</Target>
<Target Name="DocBuild" AfterTargets="Build">
<CallTarget Targets="DocValidation"/>
<CallTarget Targets="DocGenerateMetadata"/>
</Target>
<Target Name="DocValidation">
<Error Condition="!Exists($(BuildDocToolPath))" Text="docfx.exe is not found! Please check docfx.exe exists in tools folder of the package!"/>
</Target>
<Target Name="DocClean" DependsOnTargets="DocSetRebuildXDocParameter" AfterTargets="Clean">
</Target>
<Target Name="DocSetRebuildXDocParameter">
<PropertyGroup>
<RebuildDoc>True</RebuildDoc>
</PropertyGroup>
</Target>
<Target Name="DocServe">
<Exec Command="start cmd /c &quot;&quot;$(BuildDocToolPath)&quot; serve &quot;$(PreviewOutputFolder)&quot;" />
</Target>
<Target Name="DocPreview">
<Exec Condition="$(IsServing)" Command="start cmd /c &quot;&quot;$(BuildDocToolPath)&quot; build &quot;$(DocfxConfigFile)&quot; -o &quot;$(PreviewOutputFolder)&quot; --template &quot;$(DocTemplate)&quot; --serve -l &quot;$(LogFile)&quot; --logLevel &quot;$(LogLevel)&quot;&quot;" />
<Exec Condition="!$(IsServing)" Command="&quot;$(BuildDocToolPath)&quot; build &quot;$(DocfxConfigFile)&quot; -o &quot;$(PreviewOutputFolder)&quot; --template &quot;$(DocTemplate)&quot; -l &quot;$(LogFile)&quot; --logLevel &quot;$(LogLevel)&quot;" />
</Target>

<!-- ************************************************************************* -->
<!-- *************************** GenerateMetadata Phase ********************** -->
<!-- ************************************************************************* -->
<Target Name="DocGenerateMetadata" >
<PropertyGroup>
<DocGenerateCommand>&quot;$(BuildDocToolPath)&quot; &quot;$(DocfxConfigFile)&quot; -o &quot;$(OutputFolder)&quot; -l &quot;$(LogFile)&quot; --logLevel &quot;$(LogLevel)&quot;</DocGenerateCommand>
<DocGenerateCommand Condition="$(RebuildDoc)">$(DocGenerateCommand) -f</DocGenerateCommand>
<DocGenerateCommand Condition="'$(DocTemplate)' != ''">$(DocGenerateCommand) --template &quot;$(DocTemplate)&quot; </DocGenerateCommand>
<DocGenerateCommand Condition="'$(DocParameters)' != ''">$(DocGenerateCommand) $(DocParameters)</DocGenerateCommand>
</PropertyGroup>
<Message Text="Executing $(DocGenerateCommand)" />
<Exec Command="$(DocGenerateCommand)"></Exec>
</Target>
</Project>
10 changes: 10 additions & 0 deletions src/nuspec/docfx.console/content/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

###############
# folder #
###############
/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
5 changes: 5 additions & 0 deletions src/nuspec/docfx.console/content/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

###############
# temp file #
###############
*.yml
3 changes: 3 additions & 0 deletions src/nuspec/docfx.console/content/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# PLACEHOLDER
TODO: Add .NET projects to *src* folder and run `docfx` to generate a **REAL** *API Documentation*!
2 changes: 2 additions & 0 deletions src/nuspec/docfx.console/content/articles/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

# Add your introductions here!
1 change: 1 addition & 0 deletions src/nuspec/docfx.console/content/articles/toc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#[Introduction](intro.md)
68 changes: 68 additions & 0 deletions src/nuspec/docfx.console/content/docfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"metadata": [
{
"src": [
{
"files": [
"*.csproj"
],
"cwd": ".",
"exclude": [
"**/obj/**",
"**/bin/**",
"_site/**"
]
}
],
"dest": "obj/api"
}
],
"build": {
"content": [
{
"files": [
"api/**.yml"
],
"cwd": "obj"
},
{
"files": [
"api/*.md",
"articles/**.md",
"toc.yml",
"*.md"
],
"exclude": [
"obj/**",
"_site/**"
]
}
],
"resource": [
{
"files": [
"images/**"
],
"exclude": [
"obj/**",
"_site/**"
]
}
],
"overwrite": [
{
"files": [
"apidoc/**.md"
],
"exclude": [
"obj/**",
"_site/**"
]
}
],
"dest": "_site",
"template": [
"default"
]
}
}
5 changes: 5 additions & 0 deletions src/nuspec/docfx.console/content/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# This is the **HOMEPAGE**.
Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
## Quick Start Notes:
1. Add images to *images* folder if the file is referencing an image.
6 changes: 6 additions & 0 deletions src/nuspec/docfx.console/content/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

- name: Articles
href: articles/
- name: API Documentation
href: obj/api/
homepage: api/index.md
Loading

0 comments on commit 2c082bc

Please sign in to comment.