[2019-12] [corlib] add InternalsVisibleTo for Mono.Android (#18047)
[mono-project.git] / netcore / build.targets
blob80c47f9f1219941af6e4131567b791a38fd65d9a
1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 <UsingTask TaskName="ReplaceInFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
5 <ParameterGroup>
6 <Input ParameterType="System.String" Required="true" />
7 <Output ParameterType="System.String" Required="true" />
8 <Match ParameterType="System.String" Required="true" />
9 <Replace ParameterType="System.String" Required="true" />
10 </ParameterGroup>
11 <Task>
12 <Reference Include="System.Core" />
13 <Using Namespace="System" />
14 <Using Namespace="System.IO" />
15 <Using Namespace="System.Text.RegularExpressions" />
16 <Code Type="Fragment" Language="cs">
17 <![CDATA[
18 File.WriteAllText(Output, Regex.Replace(File.ReadAllText(Input), Match, Replace));
19 ]]>
20 </Code>
21 </Task>
22 </UsingTask>
24 <Import Project="$(MSBuildThisFileDirectory)..\eng\Versions.props"/>
25 <Import Project="$(MSBuildThisFileDirectory)..\msvc\mono.winconfig.targets"/>
27 <PropertyGroup>
28 <Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
29 <MONO_ENABLE_LLVM Condition="'$(MONO_ENABLE_LLVM)' == ''">false</MONO_ENABLE_LLVM>
30 <DOTNET>$(MSBuildThisFileDirectory)..\.dotnet\dotnet</DOTNET>
31 <ROSLYN_VERSION>$(MicrosoftNetCompilersVersion)</ROSLYN_VERSION>
32 <NETCORETESTS_VERSION>$(MicrosoftPrivateCoreFxNETCoreAppVersion)</NETCORETESTS_VERSION>
33 <NETCOREAPP_VERSION>$(MicrosoftNETCoreAppVersion)</NETCOREAPP_VERSION>
34 <COREARCH Condition="'$(COREARCH)' == ''">x64</COREARCH>
35 <RID Condition="'$(RID)' == ''">win-x64</RID>
36 <CORLIB_BUILD_FLAGS Condition="'$(CORLIB_BUILD_FLAGS)' == ''">-c $(Configuration)</CORLIB_BUILD_FLAGS>
37 <NETCORESDK_FILE>dotnet-runtime-$(NETCOREAPP_VERSION)-$(RID).zip</NETCORESDK_FILE>
38 <NETCORE_URL>https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$(NETCOREAPP_VERSION)/$(NETCORESDK_FILE)</NETCORE_URL>
39 <SHAREDRUNTIME>shared\Microsoft.NETCore.App\$(NETCOREAPP_VERSION)\</SHAREDRUNTIME>
40 <FEED_BASE_URL>https://dotnetfeed.blob.core.windows.net/dotnet-core</FEED_BASE_URL>
41 <TEST_ASSETS_PATH>corefx-tests/$(NETCORETESTS_VERSION)/Windows_NT.x64/netcoreapp/corefx-test-assets.xml</TEST_ASSETS_PATH>
42 <MONO_RUNTIME_BUILD_DIR>$(MSBuildThisFileDirectory)..\msvc\build\sgen\$(COREARCH)\Bin\$(Configuration)\</MONO_RUNTIME_BUILD_DIR>
43 <MONO_PRIVATE_CORLIB_BUILD_DIR>$(MSBuildThisFileDirectory)System.Private.CoreLib\bin\$(COREARCH)\</MONO_PRIVATE_CORLIB_BUILD_DIR>
44 </PropertyGroup>
46 <Target Name="configure-mono-environment-source"
47 Inputs="$(MSBuildThisFileDirectory)..\configure.ac;$(MSBuildThisFileDirectory)System.Private.CoreLib\src\System\Environment.Mono.in"
48 Outputs="$(MSBuildThisFileDirectory)System.Private.CoreLib\src\System\Environment.Mono.cs">
49 <GetVersionsFromConfigureAC ConfigFileRoot="$(MSBuildThisFileDirectory)..\">
50 <Output TaskParameter="MonoVersion" PropertyName="_MonoVersion" />
51 <Output TaskParameter="MonoCorlibVersion" PropertyName="_MonoCorlibVersion" />
52 </GetVersionsFromConfigureAC>
54 <ReplaceInFile
55 Input="$(MSBuildThisFileDirectory)System.Private.CoreLib\src\System\Environment.Mono.in"
56 Output="$(MSBuildThisFileDirectory)System.Private.CoreLib\src\System\Environment.Mono.cs"
57 Match="@MONO_CORLIB_VERSION@"
58 Replace="$(_MonoCorlibVersion)" />
59 </Target>
61 <Target Name="init-tools">
62 <Exec Command="powershell -NoProfile -NoLogo -ExecutionPolicy ByPass -Command &quot;$(MSBuildThisFileDirectory)init-tools.ps1&quot;">
63 <Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
64 </Exec>
65 </Target>
67 <Target Name="update-roslyn"
68 Condition="!Exists('$(MSBuildThisFileDirectory)roslyn\packages\microsoft.net.compilers.toolset\$(ROSLYN_VERSION)\microsoft.net.compilers.toolset.nuspec')"
69 DependsOnTargets="init-tools">
70 <PropertyGroup>
71 <_UpdateRoslynArgs>&quot;$(MSBuildThisFileDirectory)roslyn-restore.csproj&quot;</_UpdateRoslynArgs>
72 <_UpdateRoslynArgs>$(_UpdateRoslynArgs) -p:RoslynVersion=$(ROSLYN_VERSION)</_UpdateRoslynArgs>
73 <_UpdateRoslynArgs>$(_UpdateRoslynArgs) --packages &quot;$(MSBuildThisFileDirectory)roslyn\packages&quot;</_UpdateRoslynArgs>
74 <_UpdateRoslynArgs>$(_UpdateRoslynArgs) -p:OutputPath=&quot;$(MSBuildThisFileDirectory)roslyn\restore&quot;</_UpdateRoslynArgs>
75 </PropertyGroup>
76 <Exec Command="$(DOTNET) restore $(_UpdateRoslynArgs)">
77 <Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
78 </Exec>
79 </Target>
81 <Target Name="update-corefx"
82 Inputs="$(MSBuildThisFileDirectory)corefx-restore.csproj"
83 Outputs="$(MSBuildThisFileDirectory)corefx\.stamp-dl-corefx-$(NETCORETESTS_VERSION)"
84 DependsOnTargets="init-tools">
85 <PropertyGroup>
86 <_UpdateCoreFxArgs>&quot;$(MSBuildThisFileDirectory)corefx-restore.csproj&quot;</_UpdateCoreFxArgs>
87 <_UpdateCoreFxArgs>$(_UpdateCoreFxArgs) --runtime $(RID)</_UpdateCoreFxArgs>
88 <_UpdateCoreFxArgs>$(_UpdateCoreFxArgs) --packages &quot;$(MSBuildThisFileDirectory)corefx\packages&quot;</_UpdateCoreFxArgs>
89 <_UpdateCoreFxArgs>$(_UpdateCoreFxArgs) -p:MicrosoftPrivateCoreFxNETCoreAppVersion=$(NETCORETESTS_VERSION)</_UpdateCoreFxArgs>
90 <_UpdateCoreFxArgs>$(_UpdateCoreFxArgs) -p:OutputPath=&quot;$(MSBuildThisFileDirectory)corefx\restore&quot;</_UpdateCoreFxArgs>
91 </PropertyGroup>
92 <Exec Command="$(DOTNET) build $(_UpdateCoreFxArgs)">
93 <Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
94 </Exec>
95 <Touch Files="$(MSBuildThisFileDirectory)corefx\.stamp-dl-corefx-$(NETCORETESTS_VERSION)" AlwaysCreate="true" />
96 </Target>
98 <Target Name="download-unzip-netcore-sdk"
99 Condition="!Exists('$(MSBuildThisFileDirectory)$(NETCORESDK_FILE)')">
100 <DownloadFile SourceUrl="$(NETCORE_URL)" DestinationFolder="$(MSBuildThisFileDirectory)" DestinationFileName="$(NETCORESDK_FILE)" />
101 <Unzip SourceFiles="$(MSBuildThisFileDirectory)$(NETCORESDK_FILE)" DestinationFolder="$(MSBuildThisFileDirectory)" OverwriteReadOnlyFiles="true" />
102 </Target>
104 <Target Name="update-netcore-sdk"
105 Condition="!Exists('$(MSBuildThisFileDirectory)$(NETCORESDK_FILE)')">
106 <PropertyGroup>
107 <_UpdateNetCoreSdkArgs>&quot;$(MSBuildThisFileDirectory)build.targets&quot;</_UpdateNetCoreSdkArgs>
108 <_UpdateNetCoreSdkArgs>$(_UpdateNetCoreSdkArgs) /t:download-unzip-netcore-sdk</_UpdateNetCoreSdkArgs>
109 </PropertyGroup>
110 <RemoveDir Directories="$(MSBuildThisFileDirectory)shared\Microsoft.NETCore.App" />
111 <Exec Command="$(DOTNET) msbuild $(_UpdateNetCoreSdkArgs)">
112 <Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
113 </Exec>
114 </Target>
116 <Target Name="update-tests-corefx"
117 Inputs="$(MSBuildThisFileDirectory)corefx-tests-restore.proj"
118 Outputs="$(MSBuildThisFileDirectory)corefx\.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION)"
119 DependsOnTargets="init-tools">
120 <PropertyGroup>
121 <_UpdateTestsCoreFxArgs>&quot;$(MSBuildThisFileDirectory)corefx-tests-restore.proj&quot;</_UpdateTestsCoreFxArgs>
122 <_UpdateTestsCoreFxArgs>$(_UpdateTestsCoreFxArgs) -m</_UpdateTestsCoreFxArgs>
123 <_UpdateTestsCoreFxArgs>$(_UpdateTestsCoreFxArgs) -t:DownloadAllTests</_UpdateTestsCoreFxArgs>
124 <_UpdateTestsCoreFxArgs>$(_UpdateTestsCoreFxArgs) -p:TEST_ASSETS_PATH=&quot;$(TEST_ASSETS_PATH)&quot;</_UpdateTestsCoreFxArgs>
125 <_UpdateTestsCoreFxArgs>$(_UpdateTestsCoreFxArgs) -p:FEED_BASE_URL=&quot;$(FEED_BASE_URL)&quot;</_UpdateTestsCoreFxArgs>
126 </PropertyGroup>
127 <RemoveDir Directories="$(MSBuildThisFileDirectory)corefx\tests" />
128 <Exec Command="$(DOTNET) msbuild $(_UpdateTestsCoreFxArgs)">
129 <Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
130 </Exec>
131 <RemoveDir Directories="$(MSBuildThisFileDirectory)corefx\tests\extracted\System.Utf8String.Experimental.Tests" />
132 <Touch Files="$(MSBuildThisFileDirectory)corefx\.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION)" AlwaysCreate="true" />
133 </Target>
135 <Target Name="bcl" DependsOnTargets="init-tools;update-roslyn;configure-mono-environment-source">
136 <PropertyGroup>
137 <_CorlibBuildArgs>-p:TargetsWindows=true</_CorlibBuildArgs>
138 <_CorlibBuildArgs>$(_CorlibBuildArgs) $(CORLIB_BUILD_FLAGS)</_CorlibBuildArgs>
139 <_CorlibBuildArgs>$(_CorlibBuildArgs) -p:BuildArch=$(COREARCH)</_CorlibBuildArgs>
140 <_CorlibBuildArgs>$(_CorlibBuildArgs) -p:OutputPath=bin\$(COREARCH)</_CorlibBuildArgs>
141 <_CorlibBuildArgs>$(_CorlibBuildArgs) -p:RoslynPropsFile=&quot;$(MSBuildThisFileDirectory)\roslyn\packages\microsoft.net.compilers.toolset\$(ROSLYN_VERSION)\build\Microsoft.Net.Compilers.Toolset.props&quot;</_CorlibBuildArgs>
142 <_CorlibBuildArgs>$(_CorlibBuildArgs) &quot;$(MSBuildThisFileDirectory)System.Private.CoreLib\System.Private.CoreLib.csproj&quot;</_CorlibBuildArgs>
143 </PropertyGroup>
145 <Exec Command="$(DOTNET) build $(_CorlibBuildArgs)">
146 <Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
147 </Exec>
148 </Target>
150 <Target Name="build-runtime">
151 <PropertyGroup>
152 <RuntimeBuildTarget Condition="'$(RuntimeBuildTarget)' == ''">build</RuntimeBuildTarget>
153 </PropertyGroup>
154 <MSBuild Projects="$(MSBuildThisFileDirectory)..\msvc\mono.sln" Targets="$(RuntimeBuildTarget)" Properties="Platform=$(COREARCH);Configuration=$(Configuration);MONO_TARGET_GC=sgen;MONO_ENABLE_LLVM=$(MONO_ENABLE_LLVM);MONO_ENABLE_NETCORE=true"/>
155 </Target>
157 <Target Name="link-mono">
158 <Error Text="Missing Mono MSVC runtime build." Condition="!Exists('$(MONO_RUNTIME_BUILD_DIR)mono-2.0-sgen.dll')" />
159 <Error Text="Missing Mono System.Private.CoreLib build." Condition="!Exists('$(MONO_PRIVATE_CORLIB_BUILD_DIR)System.Private.CoreLib.dll')" />
160 <Copy SourceFiles="$(MONO_RUNTIME_BUILD_DIR)mono-2.0-sgen.dll" DestinationFiles="$(SHAREDRUNTIME)coreclr.dll" SkipUnchangedFiles="true" />
161 <Copy SourceFiles="$(MONO_RUNTIME_BUILD_DIR)mono-2.0-sgen.pdb" DestinationFiles="$(SHAREDRUNTIME)coreclr.pdb" SkipUnchangedFiles="true" />
162 <Copy SourceFiles="$(MONO_PRIVATE_CORLIB_BUILD_DIR)System.Private.CoreLib.dll" DestinationFiles="$(SHAREDRUNTIME)System.Private.CoreLib.dll" SkipUnchangedFiles="true" />
163 <Copy SourceFiles="$(MONO_PRIVATE_CORLIB_BUILD_DIR)System.Private.CoreLib.pdb" DestinationFiles="$(SHAREDRUNTIME)System.Private.CoreLib.pdb" SkipUnchangedFiles="true" />
164 </Target>
166 <Target Name="prepare" DependsOnTargets="update-netcore-sdk;update-corefx;update-roslyn;link-mono" />
168 <!-- To run an individual test, set property CoreFxTests to the name of the test to execute -->
169 <Target Name="run-tests-corefx" DependsOnTargets="prepare;update-tests-corefx">
170 <PropertyGroup>
171 <CoreFxTests Condition="'$(CoreFxTests)' == ''">*</CoreFxTests>
172 <CoreFxTestTimeout Condition="'$(CoreFxTestTimeout)' == ''">-1</CoreFxTestTimeout>
173 <_RunTestsCoreFxArgs>(set MONO_ENV_OPTIONS=&quot;--debug&quot;) &amp; (set COMPlus_DebugWriteToStdErr=1) &amp; </_RunTestsCoreFxArgs>
174 <_RunTestsCoreFxArgs>$(_RunTestsCoreFxArgs) powershell -NoProfile -NoLogo -ExecutionPolicy ByPass -Command &quot;$(MSBuildThisFileDirectory)run-tests-corefx.ps1&quot;</_RunTestsCoreFxArgs>
175 <_RunTestsCoreFxArgs>$(_RunTestsCoreFxArgs) -fxversion &quot;$(NETCOREAPP_VERSION)&quot; -timeout $(CoreFxTestTimeout) -corefxtests &quot;$(CoreFxTests)&quot;</_RunTestsCoreFxArgs>
176 </PropertyGroup>
178 <Exec Command="$(_RunTestsCoreFxArgs)">
179 <Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
180 </Exec>
181 </Target>
183 <Target Name="Clean">
184 <RemoveDir Directories="$(MSBuildThisFileDirectory)..\.dotnet" />
185 <RemoveDir Directories="$(MSBuildThisFileDirectory)sdk" />
186 <RemoveDir Directories="$(MSBuildThisFileDirectory)shared" />
187 <RemoveDir Directories="$(MSBuildThisFileDirectory)host" />
188 <RemoveDir Directories="$(MSBuildThisFileDirectory)dotnet" />
189 <RemoveDir Directories="$(MSBuildThisFileDirectory)corefx" />
190 <RemoveDir Directories="$(MSBuildThisFileDirectory)roslyn" />
191 <RemoveDir Directories="$(MSBuildThisFileDirectory)System.Private.CoreLib\bin" />
192 <Delete Files="$(MSBuildThisFileDirectory)$(NETCORESDK_FILE)" />
193 <Delete Files="$(MSBuildThisFileDirectory)LICENSE.txt" />
194 <Delete Files="$(MSBuildThisFileDirectory)ThirdPartyNotices.txt" />
195 <Delete Files="$(MSBuildThisFileDirectory).failures" />
196 </Target>
198 <Target Name="Build" DependsOnTargets="prepare;bcl" />
200 </Project>