forked from microsoft/CsWinRT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cmd
132 lines (113 loc) · 6.12 KB
/
build.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
@echo off
set CsWinRTNet5SdkVersion=5.0.100-preview.7.20366.6
:dotnet
rem Install required .NET 5 SDK version and add to environment
set DOTNET_ROOT=%LocalAppData%\Microsoft\dotnet
set DOTNET_ROOT(86)=%LocalAppData%\Microsoft\dotnet\x86
set path=%DOTNET_ROOT%;%path%
powershell -NoProfile -ExecutionPolicy unrestricted -Command ^
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ^
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) ^
-Version '%CsWinRTNet5SdkVersion%' -InstallDir "%DOTNET_ROOT%" -Architecture 'x64' ^
-AzureFeed 'https://dotnetcli.blob.core.windows.net/dotnet' "
powershell -NoProfile -ExecutionPolicy unrestricted -Command ^
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ^
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) ^
-Version '%CsWinRTNet5SdkVersion%' -InstallDir "%DOTNET_ROOT(86)%" -Architecture 'x86' ^
-AzureFeed 'https://dotnetcli.blob.core.windows.net/dotnet' "
:globaljson
rem User expected to provide global.json with allowPrerelease=true
if not exist %~dp0global.json (
echo Creating default global.json to allowPrelease for unit test project builds
echo { > global.json
echo "sdk": { >> global.json
echo "version": "%CsWinRTNet5SdkVersion%", >> global.json
echo "allowPrerelease": true >> global.json
echo } >> global.json
echo } >> global.json
)
rem Preserve above for Visual Studio launch inheritance
setlocal ENABLEDELAYEDEXPANSION
:params
set cswinrt_platform=%1
set cswinrt_configuration=%2
set cswinrt_version_number=%3
set cswinrt_version_string=%4
set "%5"!="" set cswinrt_label=%5
if "%cswinrt_platform%"=="" set cswinrt_platform=x64
if /I "%cswinrt_platform%" equ "all" (
if "%cswinrt_configuration%"=="" (
set cswinrt_configuration=all
)
call %0 x86 !cswinrt_configuration! !cswinrt_version!
call %0 x64 !cswinrt_configuration! !cswinrt_version!
call %0 arm !cswinrt_configuration! !cswinrt_version!
call %0 arm64 !cswinrt_configuration! !cswinrt_version!
goto :eof
)
if /I "%cswinrt_configuration%" equ "all" (
call %0 %cswinrt_platform% Debug !cswinrt_version!
call %0 %cswinrt_platform% Release !cswinrt_version!
goto :eof
)
if "%cswinrt_configuration%"=="" (
set cswinrt_configuration=Release
)
if "%cswinrt_version_number%"=="" set cswinrt_version_number=0.0.0.0
if "%cswinrt_version_string%"=="" set cswinrt_version_string=0.0.0-private.0
rem Generate prerelease targets file to exercise build warnings
set prerelease_targets=nuget\Microsoft.Windows.CsWinRT.Prerelease.targets
if not exist %prerelease_targets% (
echo Creating default %prerelease_targets%
echo ^<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="CsWinRTVerifyPrerelease"^> > %prerelease_targets%
echo ^<Target Name="CsWinRTVerifyPrerelease" >> %prerelease_targets%
echo Condition="'$(NetCoreSdkVersion)' ^!= '%CsWinRTNet5SdkVersion%' and '$(Net5SdkVersion)' ^!= '%CsWinRTNet5SdkVersion%'"^> >> %prerelease_targets%
echo ^<Warning Text="This C#/WinRT prerelease is designed for .Net SDK %CsWinRTNet5SdkVersion%. Other prereleases may be incompatible due to breaking changes." /^> >> %prerelease_targets%
echo ^</Target^> >> %prerelease_targets%
echo ^</Project^> >> %prerelease_targets%
)
if not "%cswinrt_label%"=="" goto %cswinrt_label%
:restore
if not exist .nuget md .nuget
if not exist .nuget\nuget.exe powershell -Command "Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v5.6.0/nuget.exe -OutFile .nuget\nuget.exe"
.nuget\nuget update -self
.nuget\nuget.exe restore
:build
call get_testwinrt.cmd
echo Building cswinrt for %cswinrt_platform% %cswinrt_configuration%
msbuild cswinrt.sln %cswinrt_build_params% /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%;VersionNumber=%cswinrt_version_number%;VersionString=%cswinrt_version_string%;GenerateTestProjection=true
:test
rem Build/Run xUnit tests, generating xml output report for Azure Devops reporting, via XunitXml.TestLogger NuGet
echo Running cswinrt unit tests for %cswinrt_platform% %cswinrt_configuration%
set dotnet_exe="%DOTNET_ROOT%\dotnet.exe"
if not exist %dotnet_exe% (
if %cswinrt_platform%==x86 (
set dotnet_exe="%ProgramFiles(x86)%\dotnet\dotnet.exe"
) else (
set dotnet_exe="%ProgramFiles%\dotnet\dotnet.exe"
)
)
rem WinUI NuGet package's Microsoft.WinUI.AppX.targets attempts to import a file that does not exist, even when
rem executing "dotnet test --no-build ...", which evidently still needs to parse and load the entire project.
rem Work around by using a dummy targets file and assigning it to the MsAppxPackageTargets property.
echo ^<Project/^> > %temp%\EmptyMsAppxPackage.Targets
%dotnet_exe% test --no-build --logger xunit;LogFilePath=%~dp0unittest_%cswinrt_version_string%.xml unittest/UnitTest.csproj /nologo /m /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%;MsAppxPackageTargets=%temp%\EmptyMsAppxPackage.Targets
if ErrorLevel 1 (
echo.
echo ERROR: Unit test failed, skipping NuGet pack
exit /b !ErrorLevel!
)
rem Run WinRT.Host tests
%~dp0_build\%cswinrt_platform%\%cswinrt_configuration%\HostTest\bin\HostTest.exe --gtest_output=xml:%~dp0hosttest_%cswinrt_version_string%.xml
if ErrorLevel 1 (
echo.
echo ERROR: Host test failed, skipping NuGet pack
exit /b !ErrorLevel!
)
:package
set cswinrt_bin_dir=%~dp0_build\%cswinrt_platform%\%cswinrt_configuration%\cswinrt\bin\
set cswinrt_exe=%cswinrt_bin_dir%cswinrt.exe
set netstandard2_runtime=%~dp0WinRT.Runtime\bin\%cswinrt_configuration%\netstandard2.0\WinRT.Runtime.dll
set net5_runtime=%~dp0WinRT.Runtime\bin\%cswinrt_configuration%\net5.0\WinRT.Runtime.dll
set source_generator=%~dp0Authoring\WinRT.SourceGenerator\bin\%cswinrt_configuration%\netstandard2.0\WinRT.SourceGenerator.dll
.nuget\nuget pack nuget/Microsoft.Windows.CsWinRT.nuspec -Properties cswinrt_exe=%cswinrt_exe%;netstandard2_runtime=%netstandard2_runtime%;net5_runtime=%net5_runtime%;source_generator=%source_generator%;cswinrt_nuget_version=%cswinrt_version_string% -OutputDirectory %cswinrt_bin_dir% -NonInteractive -Verbosity Detailed -NoPackageAnalysis