Skip to content

Commit 3b449a7

Browse files
committed
Fix Windows build through core-setup
Most changes are ported from master.
1 parent 3109126 commit 3b449a7

File tree

17 files changed

+240
-78
lines changed

17 files changed

+240
-78
lines changed

build.proj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,20 @@
3131
<RemoveDir Directories="$(BaseOutputPath)" />
3232
</Target>
3333

34+
<!--
35+
Workaround: Skip Windows_NT.
36+
37+
When trying to CopyReferenceOnlyPackages, it gets errors like:
38+
39+
System.IO.IOException: The process cannot access the file
40+
'<root>\packages\microsoft.codeanalysis.compilers\2.6.0-beta3-62316-02\microsoft.codeanalysis.compilers.nuspec'
41+
because it is being used by another process.
42+
43+
We don't support producing a tarball on Windows, so there's little value in fixing this.
44+
-->
3445
<Target Name="CopyAndDisassembleReferenceOnlyPackages"
3546
AfterTargets="Build"
36-
Condition="'$(OfflineBuild)' != 'true'">
47+
Condition="'$(OfflineBuild)' != 'true' and '$(OS)' != 'Windows_NT'">
3748

3849
<CopyReferenceOnlyPackages
3950
PackageCacheDir="$(PackagesDir)"

build.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function Exec-Block([scriptblock]$cmd) {
2323

2424
$SCRIPT_ROOT = "$PSScriptRoot"
2525
$SdkVersion = Get-Content (Join-Path $SCRIPT_ROOT "DotnetCLIVersion.txt")
26+
$env:SDK_VERSION = $SdkVersion
2627

2728
if ([string]::IsNullOrWhiteSpace($env:SOURCE_BUILD_SKIP_SUBMODULE_CHECK) -or $env:SOURCE_BUILD_SKIP_SUBMODULE_CHECK -eq "0" -or $env:SOURCE_BUILD_SKIP_SUBMODULE_CHECK -eq "false")
2829
{

dir.props

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<PrebuiltPackagesPath>$(ProjectDir)prebuilt/nuget-packages/</PrebuiltPackagesPath>
6262
<PrebuiltSourceBuiltPackagesPath>$(ProjectDir)prebuilt/source-built/</PrebuiltSourceBuiltPackagesPath>
6363
<SourceBuiltTarBallPath>$(OutputPath)</SourceBuiltTarBallPath>
64+
<SourceBuiltRuntimeDir>$(LocalBlobStorageRoot)Runtime/</SourceBuiltRuntimeDir>
6465
<TargetInfoProps>$(IntermediatePath)TargetInfo.props</TargetInfoProps>
6566
<RestoreSourcePropsPath>$(IntermediatePath)RestoreSources.props</RestoreSourcePropsPath>
6667
<PackageVersionPropsPath>$(IntermediatePath)PackageVersions.props</PackageVersionPropsPath>
@@ -107,15 +108,11 @@
107108
<Import Project="$(ProjectDir)dependencies.props" />
108109

109110
<PropertyGroup>
110-
<!--
111-
Temporarily update RootRepo to known-good
112-
repo project until all repos are building clean.
113-
When all repos build, this can be changed back
114-
to cli.
115-
<RootRepo>cli</RootRepo>
116-
-->
111+
<!-- known-good (repos/known-good.proj) conditionally includes submodules based on the platform,
112+
so this will not always correspond to the same repos - see that file for details.
113+
We need an "empty" project after the last real project in order for prebuilt detection
114+
to work, so we always build known-good. -->
117115
<RootRepo>known-good</RootRepo>
118-
<RootRepo Condition="$(Platform.Contains('arm'))">core-setup</RootRepo>
119116
</PropertyGroup>
120117

121118
<ItemGroup>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
From f8222748c2c3163593c736d6f4868efd6451f16b Mon Sep 17 00:00:00 2001
2+
From: Davis Goodin <dagood@microsoft.com>
3+
Date: Fri, 16 Nov 2018 15:04:54 -0600
4+
Subject: [PATCH] Copy run.cmd changes from corefx
5+
6+
This uses .NET Core msbuild, not desktop
7+
---
8+
run.cmd | 54 +++++++++++++++++++++++++++++++++++++++++++-----------
9+
1 file changed, 43 insertions(+), 11 deletions(-)
10+
11+
diff --git a/run.cmd b/run.cmd
12+
index 1da6c1e..7a2fb13 100644
13+
--- a/run.cmd
14+
+++ b/run.cmd
15+
@@ -1,28 +1,60 @@
16+
-@if "%_echo%" neq "on" echo off
17+
+@if not defined _echo @echo off
18+
setlocal
19+
20+
-if not defined VisualStudioVersion (
21+
- if defined VS140COMNTOOLS (
22+
- call "%VS140COMNTOOLS%\VsDevCmd.bat"
23+
- goto :Run
24+
- )
25+
- echo Error: Visual Studio 2015 required.
26+
+:: Default to highest Visual Studio version available
27+
+::
28+
+:: For VS2015 (and prior), only a single instance is allowed to be installed on a box
29+
+:: and VS140COMNTOOLS is set as a global environment variable by the installer. This
30+
+:: allows users to locate where the instance of VS2015 is installed.
31+
+::
32+
+:: For VS2017, multiple instances can be installed on the same box SxS and VS150COMNTOOLS
33+
+:: is no longer set as a global environment variable and is instead only set if the user
34+
+:: has launched the VS2017 Developer Command Prompt.
35+
+::
36+
+:: Following this logic, we will default to the VS2017 toolset if VS150COMNTOOLS tools is
37+
+:: set, as this indicates the user is running from the VS2017 Developer Command Prompt and
38+
+:: is already configured to use that toolset. Otherwise, we will fallback to using the VS2015
39+
+:: toolset if it is installed. Finally, we will fail the script if no supported VS instance
40+
+:: can be found.
41+
+
42+
+if defined VisualStudioVersion goto :Run
43+
+
44+
+set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
45+
+if exist %_VSWHERE% (
46+
+ for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -prerelease -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools
47+
+)
48+
+if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS%
49+
+if not exist "%_VSCOMNTOOLS%" (
50+
+ echo Error: Visual Studio 2015 or 2017 required.
51+
echo Please see https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
52+
exit /b 1
53+
)
54+
55+
+call "%_VSCOMNTOOLS%\VsDevCmd.bat"
56+
+
57+
:Run
58+
:: Clear the 'Platform' env variable for this session, as it's a per-project setting within the build, and
59+
:: misleading value (such as 'MCD' in HP PCs) may lead to build breakage (issue: #69).
60+
set Platform=
61+
62+
+:: Disable telemetry, first time experience, and global sdk look for the CLI
63+
+set DOTNET_CLI_TELEMETRY_OPTOUT=1
64+
+set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
65+
+set DOTNET_MULTILEVEL_LOOKUP=0
66+
+
67+
:: Restore the Tools directory
68+
-call "%~dp0init-tools.cmd"
69+
+call %~dp0init-tools.cmd
70+
if NOT [%ERRORLEVEL%]==[0] exit /b 1
71+
72+
set _toolRuntime=%~dp0Tools
73+
set _dotnet=%_toolRuntime%\dotnetcli\dotnet.exe
74+
+set _json=%~dp0config.json
75+
+
76+
+:: run.exe depends on running in the root directory, notably because the config.json specifies
77+
+:: a relative path to the binclash logger
78+
+
79+
+pushd %~dp0
80+
+call %_dotnet% %_toolRuntime%\run.exe "%_json%" %*
81+
+popd
82+
83+
-echo Running: "%_dotnet%" "%_toolRuntime%\run.exe" %*
84+
-call "%_dotnet%" "%_toolRuntime%\run.exe" %*
85+
-exit /b %ERRORLEVEL%
86+
\ No newline at end of file
87+
+exit /b %ERRORLEVEL%
88+
--
89+
2.17.1.windows.2
90+

repos/clicommandlineparser.proj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))/dir.props" />
44
<PropertyGroup>
5-
<BuildCommandArgs>--restore --pack --configuration $(Configuration)</BuildCommandArgs>
5+
<!-- In Windows -restore is already passed by default by build.cmd to build.ps1 -->
6+
<BuildCommandArgs>$(FlagParameterPrefix)pack $(FlagParameterPrefix)configuration $(Configuration)</BuildCommandArgs>
7+
<BuildCommandArgs Condition="'$(OS)' != 'Windows_NT'">$(BuildCommandArgs) $(FlagParameterPrefix)restore</BuildCommandArgs>
68

79
<!-- Pass in package version props using the Product Construction (ProdCon) API. -->
810
<BuildCommandArgs>$(BuildCommandArgs) /p:PB_PackageVersionPropsUrl=file:%2F%2F$(PackageVersionPropsPath)</BuildCommandArgs>

repos/core-setup.proj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,26 @@
4949
<CoreSetupTarballs Include="$(SourceBuiltAssetsDir)dotnet-hostfxr-*$(TarBallExtension)" />
5050
</ItemGroup>
5151
<PublishCoreSetupBinaries Binaries="@(CoreSetupTarballs)"
52-
DestinationFolderTemplate="$(LocalBlobStorageRoot)Runtime/{version}/" />
52+
DestinationFolderTemplate="$(SourceBuiltRuntimeDir){version}/" >
53+
<Output TaskParameter="PublishedVersion" PropertyName="PublishedVersion" />
54+
</PublishCoreSetupBinaries>
55+
<Message Text="Published core-setup binaries version $(PublishedVersion)" Importance="High" />
56+
</Target>
57+
58+
59+
<Target Name="CopyBinariesToBinFolder" AfterTargets="PublishBinaries">
60+
<ItemGroup>
61+
<_builtRuntimePackages Include="$(SourceBuiltAssetsDir)*.symbols.nupkg" />
62+
<_builtRuntimePackages>
63+
<TransformedFileName>$([System.String]::Copy('%(FileName)').Replace('symbols', 'nupkg'))</TransformedFileName>
64+
</_builtRuntimePackages>
65+
<BinariesToCopy Include="$(SourceBuiltAssetsDir)*.*" Exclude="$(SourceBuiltAssetsDir)*.nupkg;$(SourceBuiltAssetsDir)*.requires_nupkg_signing" />
66+
<BinariesToCopy Include="@(_builtRuntimePackages->'$(SourceBuiltPackagesPath)%(TransformedFileName)')" />
67+
</ItemGroup>
68+
69+
<Copy SourceFiles="@(BinariesToCopy)"
70+
DestinationFolder="$(OutputPath)runtime"
71+
Condition="'@(BinariesToCopy)'!=''" />
5372
</Target>
5473

5574
</Project>

repos/coreclr.proj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))/dir.props" />
44
<PropertyGroup>
5-
<!-- core-setup uses the portable RID for OSX all the time, so override -->
6-
<OverridePortableBuild>$(PortableBuild)</OverridePortableBuild>
7-
<OverridePortableBuild Condition="'$(TargetOS)' == 'OSX'">true</OverridePortableBuild>
8-
95
<BuildArguments>$(Platform) $(Configuration) skiptests</BuildArguments>
10-
<BuildArguments>$(BuildArguments) -PortableBuild=$(OverridePortableBuild)</BuildArguments>
116
<BuildArguments Condition="'$(SkipDisablePgo)' != 'true'">$(BuildArguments) -nopgooptimize</BuildArguments>
127
<BuildArguments Condition="'$(OS)' != 'Windows_NT'">$(BuildArguments) msbuildonunsupportedplatform</BuildArguments>
13-
<BuildArguments Condition="'$(UseSystemLibraries)' == 'true'">$(BuildArguments) cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE</BuildArguments>
8+
<BuildArguments Condition="'$(UseSystemLibraries)' == 'true' AND '$(OS)' != 'Windows_NT'">$(BuildArguments) cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE</BuildArguments>
149
<BuildArguments Condition="$(Platform.Contains('arm'))">$(BuildArguments) skipnuget cross -skiprestore cmakeargs -DFEATURE_GDBJIT=TRUE</BuildArguments>
10+
<!-- Portable builds only apply to Linux - Mac and Windows are both always portable.
11+
Additionally, Linux builds are portable by default and only have a switch to turn it off -->
12+
<BuildArguments Condition="'$(TargetOS)' == 'Linux' and '$(PortableBuild)' == 'false'">$(BuildArguments) -PortableBuild=false</BuildArguments>
13+
1514
<BuildArguments>$(BuildArguments) --</BuildArguments>
1615

1716
<BuildCommand>$(ProjectDirectory)/build$(ShellExtension) $(BuildArguments)</BuildCommand>

repos/corefx.proj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
<PropertyGroup>
55
<!-- OSX core-setup build always uses the portable RID, so override it -->
66
<OverridePortableBuild>$(PortableBuild)</OverridePortableBuild>
7-
<OverridePortableBuild Condition="'$(TargetOS)' == 'OSX'">true</OverridePortableBuild>
7+
<OverridePortableBuild Condition="'$(TargetOS)' == 'OSX' OR '$(TargetOS)' == 'Windows_NT'">true</OverridePortableBuild>
88
<OverrideTargetRid>$(TargetRid)</OverrideTargetRid>
99
<OverrideTargetRid Condition="'$(TargetOS)' == 'OSX'">osx-x64</OverrideTargetRid>
10+
<OverrideTargetRid Condition="'$(TargetOS)' == 'Windows_NT'">win-x64</OverrideTargetRid>
1011

1112
<BuildArguments>-$(Configuration)</BuildArguments>
1213
<BuildArguments>$(BuildArguments) -buildArch=$(Platform)</BuildArguments>
@@ -15,6 +16,7 @@
1516
<BuildArguments>$(BuildArguments) -PackageRid=$(OverrideTargetRid)</BuildArguments>
1617
<BuildArguments>$(BuildArguments) --</BuildArguments>
1718
<BuildArguments>$(BuildArguments) /p:BuildAllPackages=true</BuildArguments>
19+
<BuildArguments Condition="'$(TargetOS)' == 'Windows_NT'">$(BuildArguments) /p:ILLinkTrimAssembly=false</BuildArguments>
1820
<BuildArguments>$(BuildArguments) /bl</BuildArguments>
1921

2022
<BuildCommand>$(ProjectDirectory)/build$(ShellExtension) $(BuildArguments)</BuildCommand>

repos/dir.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<PropertyGroup>
1717
<OutputGitInfoPropsFile>$(GitInfoOutputDir)$(RepositoryName).props</OutputGitInfoPropsFile>
1818
<OfflineGitInfoPropsFile>$(GitInfoOfflineDir)$(RepositoryName).props</OfflineGitInfoPropsFile>
19+
<FlagParameterPrefix Condition="'$(OS)' == 'Windows_NT'">-</FlagParameterPrefix>
20+
<FlagParameterPrefix Condition="'$(OS)' != 'Windows_NT'">--</FlagParameterPrefix>
1921
</PropertyGroup>
2022

2123
<Import Project="$(OutputGitInfoPropsFile)" Condition="Exists('$(OutputGitInfoPropsFile)')" />

repos/known-good.proj

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,69 @@
66
<OrchestratedManifestBuildName>N/A</OrchestratedManifestBuildName>
77
</PropertyGroup>
88

9-
<ItemGroup>
10-
<!-- Toolsets -->
11-
<RepositoryReference Include="roslyn-tools" />
12-
13-
<!-- Tier 1 -->
14-
<RepositoryReference Include="application-insights" />
15-
<RepositoryReference Include="common" />
16-
<RepositoryReference Include="netcorecli-fsc" />
17-
<RepositoryReference Include="newtonsoft-json" />
18-
<RepositoryReference Include="standard" />
19-
<RepositoryReference Include="xliff-tasks" />
20-
21-
<RepositoryReference Include="clicommandlineparser" />
22-
<RepositoryReference Include="roslyn" />
23-
24-
<!-- Tier 2 -->
25-
<RepositoryReference Include="aspnet-razor" />
26-
<RepositoryReference Include="msbuild" />
27-
<RepositoryReference Include="nuget-client" />
28-
<RepositoryReference Include="websdk" />
29-
<RepositoryReference Include="coreclr" />
30-
31-
<RepositoryReference Include="templating" />
32-
33-
<!-- Tier 3 -->
34-
35-
<RepositoryReference Include="corefx" />
36-
37-
<!-- Tier 4 -->
38-
39-
<RepositoryReference Include="core-setup" />
40-
41-
<!-- Tier 5 -->
42-
43-
<RepositoryReference Include="sdk" />
44-
<RepositoryReference Include="vstest" />
45-
<RepositoryReference Include="cli-migrate" />
46-
<RepositoryReference Include="fsharp" />
47-
48-
<!-- Tier 6 -->
49-
50-
<RepositoryReference Include="cli" />
51-
52-
</ItemGroup>
9+
<!-- This project file serves a couple of purpose.
10+
- We conditionally include repos based on what works on different platforms/configurations.
11+
- We need an "empty" build after the last real repo for prebuilt detection to work - this is that file.
12+
- If we have a repo that is not in core-sdk's dependency tree, we can still build it by including it here. -->
13+
14+
<!-- Windows and ARM builds currently only work through core-setup -->
15+
<Choose>
16+
<When Condition="'$(OS)' == 'Windows_NT'">
17+
<ItemGroup>
18+
<RepositoryReference Include="core-setup" />
19+
</ItemGroup>
20+
</When>
21+
<When Condition="$(Platform.Contains('arm'))">
22+
<ItemGroup>
23+
<RepositoryReference Include="core-setup" />
24+
</ItemGroup>
25+
</When>
26+
<Otherwise>
27+
<ItemGroup>
28+
<!-- Toolsets -->
29+
<RepositoryReference Include="roslyn-tools" />
30+
31+
<!-- Tier 1 -->
32+
<RepositoryReference Include="application-insights" />
33+
<RepositoryReference Include="common" />
34+
<RepositoryReference Include="netcorecli-fsc" />
35+
<RepositoryReference Include="newtonsoft-json" />
36+
<RepositoryReference Include="standard" />
37+
<RepositoryReference Include="xliff-tasks" />
38+
39+
<RepositoryReference Include="clicommandlineparser" />
40+
<RepositoryReference Include="roslyn" />
41+
42+
<!-- Tier 2 -->
43+
<RepositoryReference Include="aspnet-razor" />
44+
<RepositoryReference Include="msbuild" />
45+
<RepositoryReference Include="nuget-client" />
46+
<RepositoryReference Include="websdk" />
47+
<RepositoryReference Include="coreclr" />
48+
49+
<RepositoryReference Include="templating" />
50+
51+
<!-- Tier 3 -->
52+
53+
<RepositoryReference Include="corefx" />
54+
55+
<!-- Tier 4 -->
56+
57+
<RepositoryReference Include="core-setup" />
58+
59+
<!-- Tier 5 -->
60+
61+
<RepositoryReference Include="sdk" />
62+
<RepositoryReference Include="vstest" />
63+
<RepositoryReference Include="cli-migrate" />
64+
<RepositoryReference Include="fsharp" />
65+
66+
<!-- Tier 6 -->
67+
68+
<RepositoryReference Include="cli" />
69+
</ItemGroup>
70+
</Otherwise>
71+
</Choose>
5372

5473
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))/dir.targets" />
5574

0 commit comments

Comments
 (0)