Skip to content

Commit 26e0a36

Browse files
authored
Merge pull request #8960 from dotnet/merges/master-to-release/fsharp5
Merge master to release/fsharp5
2 parents dc7eb53 + 2bf6598 commit 26e0a36

File tree

6 files changed

+187
-25
lines changed

6 files changed

+187
-25
lines changed

FSharpBuild.Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
44
<Import Project="eng\targets\Imports.targets" />
5+
<Import Project="eng\targets\NGenBinaries.targets" />
56
<Import Project="eng\targets\NuGet.targets" />
67
<Import Project="FSharp.Profiles.props" />
78

eng/Build.ps1

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,17 @@ function BuildCompiler() {
273273
$argNoRestore = if ($norestore) { " --no-restore" } else { "" }
274274
$argNoIncremental = if ($rebuild) { " --no-incremental" } else { "" }
275275

276+
if ($binaryLog) {
277+
$logFilePath = Join-Path $LogDir "fscBootstrapLog.binlog"
278+
$args += " /bl:$logFilePath"
279+
}
276280
$args = "build $fscProject -c $configuration -v $verbosity -f netcoreapp3.0" + $argNoRestore + $argNoIncremental
277281
Exec-Console $dotnetExe $args
278282

283+
if ($binaryLog) {
284+
$logFilePath = Join-Path $LogDir "fsiBootstrapLog.binlog"
285+
$args += " /bl:$logFilePath"
286+
}
279287
$args = "build $fsiProject -c $configuration -v $verbosity -f netcoreapp3.0" + $argNoRestore + $argNoIncremental
280288
Exec-Console $dotnetExe $args
281289
}
@@ -286,6 +294,100 @@ function Prepare-TempDir() {
286294
Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.targets") $TempDir
287295
}
288296

297+
function DownloadDotnetFrameworkSdk() {
298+
$dlTempPath = [System.IO.Path]::GetTempPath()
299+
$dlRandomFile = [System.IO.Path]::GetRandomFileName()
300+
$net48Dir = Join-Path $dlTempPath $dlRandomFile
301+
Create-Directory $net48Dir
302+
303+
$net48Exe = Join-Path $net48Dir "ndp48-devpack-enu.exe"
304+
$dlLogFilePath = Join-Path $LogDir "dotnet48.install.log"
305+
Invoke-WebRequest "https://go.microsoft.com/fwlink/?linkid=2088517" -OutFile $net48Exe
306+
307+
Write-Host "Exec-Console $net48Exe /install /quiet /norestart /log $dlLogFilePath"
308+
Exec-Console $net48Exe "/install /quiet /norestart /log $dlLogFilePath"
309+
}
310+
311+
function Test-IsAdmin {
312+
([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
313+
}
314+
315+
function TryDownloadDotnetFrameworkSdk() {
316+
# If we are not running as admin user, don't bother grabbing ndp sdk -- since we don't need sn.exe
317+
$isAdmin = Test-IsAdmin
318+
Write-Host "TryDownloadDotnetFrameworkSdk -- Test-IsAdmin = '$isAdmin'"
319+
if ($isAdmin -eq $true)
320+
{
321+
# Get program files(x86) location
322+
if (${env:ProgramFiles(x86)} -eq $null) {
323+
$programFiles = $env:ProgramFiles
324+
}
325+
else {
326+
$programFiles = ${env:ProgramFiles(x86)}
327+
}
328+
329+
# Get windowsSDK location for x86
330+
$windowsSDK_ExecutablePath_x86 = $env:WindowsSDK_ExecutablePath_x86
331+
$newWindowsSDK_ExecutablePath_x86 = Join-Path "$programFiles" "Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools"
332+
333+
if ($windowsSDK_ExecutablePath_x86 -eq $null) {
334+
$snPathX86 = Join-Path $newWindowsSDK_ExecutablePath_x86 "sn.exe"
335+
}
336+
else {
337+
$snPathX86 = Join-Path $windowsSDK_ExecutablePath_x86 "sn.exe"
338+
$snPathX86Exists = Test-Path $snPathX86 -PathType Leaf
339+
if ($snPathX86Exists -ne $true) {
340+
$windowsSDK_ExecutablePath_x86 = null
341+
$snPathX86 = Join-Path $newWindowsSDK_ExecutablePath_x86 "sn.exe"
342+
}
343+
}
344+
345+
$windowsSDK_ExecutablePath_x64 = $env:WindowsSDK_ExecutablePath_x64
346+
$newWindowsSDK_ExecutablePath_x64 = Join-Path "$programFiles" "Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64"
347+
348+
if ($windowsSDK_ExecutablePath_x64 -eq $null) {
349+
$snPathX64 = Join-Path $newWindowsSDK_ExecutablePath_x64 "sn.exe"
350+
}
351+
else {
352+
$snPathX64 = Join-Path $windowsSDK_ExecutablePath_x64 "sn.exe"
353+
$snPathX64Exists = Test-Path $snPathX64 -PathType Leaf
354+
if ($snPathX64Exists -ne $true) {
355+
$windowsSDK_ExecutablePath_x86 = null
356+
$snPathX64 = Join-Path $newWindowsSDK_ExecutablePath_x64 "sn.exe"
357+
}
358+
}
359+
360+
$snPathX86Exists = Test-Path $snPathX86 -PathType Leaf
361+
Write-Host "pre-dl snPathX86Exists : $snPathX86Exists - '$snPathX86'"
362+
if ($snPathX86Exists -ne $true) {
363+
DownloadDotnetFrameworkSdk
364+
}
365+
366+
$snPathX86Exists = Test-Path $snPathX86 -PathType Leaf
367+
if ($snPathX86Exists -eq $true) {
368+
if ($windowsSDK_ExecutablePath_x86 -ne $newWindowsSDK_ExecutablePath_x86) {
369+
$windowsSDK_ExecutablePath_x86 = $newWindowsSDK_ExecutablePath_x86
370+
# x86 environment variable
371+
Write-Host "set WindowsSDK_ExecutablePath_x86=$WindowsSDK_ExecutablePath_x86"
372+
[System.Environment]::SetEnvironmentVariable("WindowsSDK_ExecutablePath_x86","$newWindowsSDK_ExecutablePath_x86",[System.EnvironmentVariableTarget]::Machine)
373+
$env:WindowsSDK_ExecutablePath_x86 = $newWindowsSDK_ExecutablePath_x86
374+
}
375+
}
376+
377+
# Also update environment variable for x64
378+
$snPathX64Exists = Test-Path $snPathX64 -PathType Leaf
379+
if ($snPathX64Exists -eq $true) {
380+
if ($windowsSDK_ExecutablePath_x64 -ne $newWindowsSDK_ExecutablePath_x64) {
381+
$windowsSDK_ExecutablePath_x64 = $newWindowsSDK_ExecutablePath_x64
382+
# x64 environment variable
383+
Write-Host "set WindowsSDK_ExecutablePath_x64=$WindowsSDK_ExecutablePath_x64"
384+
[System.Environment]::SetEnvironmentVariable("WindowsSDK_ExecutablePath_x64","$newWindowsSDK_ExecutablePath_x64",[System.EnvironmentVariableTarget]::Machine)
385+
$env:WindowsSDK_ExecutablePath_x64 = $newWindowsSDK_ExecutablePath_x64
386+
}
387+
}
388+
}
389+
}
390+
289391
function EnablePreviewSdks() {
290392
if (Test-Path variable:global:_MSBuildExe) {
291393
return
@@ -322,9 +424,11 @@ try {
322424
EnablePreviewSdks
323425
}
324426

427+
$buildTool = InitializeBuildTool
428+
$toolsetBuildProj = InitializeToolset
429+
TryDownloadDotnetFrameworkSdk
325430
if ($bootstrap) {
326431
$script:BuildMessage = "Failure building bootstrap compiler"
327-
$toolsetBuildProj = InitializeToolset
328432
$bootstrapDir = Make-BootstrapBuild
329433
}
330434

eng/build-utils.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ function Make-BootstrapBuild() {
245245
$argNoIncremental = if ($rebuild) { " --no-incremental" } else { "" }
246246

247247
$args = "build $buildToolsProject -c $bootstrapConfiguration -v $verbosity -f netcoreapp3.0" + $argNoRestore + $argNoIncremental
248+
if ($binaryLog) {
249+
$logFilePath = Join-Path $LogDir "toolsBootstrapLog.binlog"
250+
$args += " /bl:$logFilePath"
251+
}
248252
Exec-Console $dotnetExe $args
249253

250254
Copy-Item "$ArtifactsDir\bin\fslex\$bootstrapConfiguration\netcoreapp3.0" -Destination "$dir\fslex" -Force -Recurse
@@ -254,6 +258,10 @@ function Make-BootstrapBuild() {
254258
# prepare compiler
255259
$protoProject = "$RepoRoot\proto.proj"
256260
$args = "build $protoProject -c $bootstrapConfiguration -v $verbosity -f $bootstrapTfm" + $argNoRestore + $argNoIncremental
261+
if ($binaryLog) {
262+
$logFilePath = Join-Path $LogDir "protoBootstrapLog.binlog"
263+
$args += " /bl:$logFilePath"
264+
}
257265
Exec-Console $dotnetExe $args
258266

259267
Copy-Item "$ArtifactsDir\bin\fsc\$bootstrapConfiguration\$bootstrapTfm" -Destination "$dir\fsc" -Force -Recurse

eng/common/tools.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
286286
if (Test-Path variable:global:_MSBuildExe) {
287287
return $global:_MSBuildExe
288288
}
289-
290289
if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }
291290
$vsMinVersionStr = if ($vsRequirements.version) { $vsRequirements.version } else { '15.9' }
292291
$vsMinVersion = [Version]::new($vsMinVersionStr)
@@ -632,6 +631,7 @@ function MSBuild-Core() {
632631
}
633632
}
634633

634+
Write-Host "$buildTool.Path: $buildTool.Path --- $cmdArgs"
635635
$exitCode = Exec-Process $buildTool.Path $cmdArgs
636636

637637
if ($exitCode -ne 0) {

eng/targets/NGenBinaries.targets

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,70 @@
11
<Project>
22

3-
<!-- Windows permissions means that users can't even see the directory $(SystemRoot)System32\config -->
4-
<PropertyGroup Condition="'$(OS)' != 'Unix' AND Exists('$(SystemRoot)\System32\config\system')">
5-
<IsAdministrator>true</IsAdministrator>
6-
<DelaySign>true</DelaySign>
7-
<PublicSign>false</PublicSign>
8-
</PropertyGroup>
3+
<Target Name="SetIsAdministrator" Condition="'$(OS)' != 'Unix'"
4+
BeforeTargets="MaybeSetSigning">
5+
<Exec Command="net session &gt;nul 2&gt;&amp;1" ConsoleToMSBuild="true" IgnoreExitCode="true">
6+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
7+
</Exec>
8+
<PropertyGroup>
9+
<IsAdministrator Condition="'$(ErrorCode)' != '0'">false</IsAdministrator>
10+
<IsAdministrator Condition="'$(ErrorCode)' == '0'">true</IsAdministrator>
11+
</PropertyGroup>
12+
</Target>
13+
14+
<Target Name="MaybeSetSigning"
15+
BeforeTargets="CoreCompile"
16+
AfterTargets="BeforeCoreCompile"
17+
Condition="'$(OS)' != 'Unix'">
18+
19+
<PropertyGroup Condition="'$(IsAdministrator)' == 'true' ">
20+
<DelaySign>true</DelaySign>
21+
<PublicSign>false</PublicSign>
22+
</PropertyGroup>
23+
</Target>
924

1025
<Target Name="NGenWindowsBinaries"
11-
AfterTargets="AfterBuild"
12-
Condition="'$(OS)' != 'Unix' AND
13-
$(TargetFramework.StartsWith('net4')) AND
14-
'$(NGenBinary)' == 'true' AND
15-
Exists('$(TargetPath)') ">
26+
AfterTargets="Build"
27+
Condition="'$(OS)' != 'Unix' AND $(TargetFramework.StartsWith('net4')) AND '$(NGenBinary)' == 'true' AND '$(IsAdministrator)' == 'true' AND Exists('$(TargetPath)') ">
28+
1629
<PropertyGroup>
17-
<PathToNGen64>$(windir)\Microsoft.NET\Framework64\v4.0.30319\ngen.exe</PathToNGen64>
1830
<PathToNGen32>$(windir)\Microsoft.NET\Framework\v4.0.30319\ngen.exe</PathToNGen32>
19-
<PathToSN32>$(WindowsSDK_ExecutablePath_x86)sn.exe</PathToSN32>
31+
<PathToNGen64>$(windir)\Microsoft.NET\Framework64\v4.0.30319\ngen.exe</PathToNGen64>
2032
</PropertyGroup>
2133

22-
<!--
23-
Enable Skip Verification and then NGen for both 32 and 64 bit product.
24-
If compiling use the app config file, if present.
25-
-->
26-
<Exec Command='"$(PathToSN32)" /Vr "$(TargetPath)"' Condition = "Exists('$(PathToSN32)') AND Exists('$(TargetPath)') AND '$(IsAdministrator)' == 'true'"/>
34+
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)" /nologo /silent /ExeConfig:$(TargetPath)'
35+
Condition = "Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND Exists('$(TargetPath).config') AND '$(OutputType)' == 'Exe' AND '$(IsAdministrator)' == 'true'"
36+
ConsoleToMSBuild="true"
37+
IgnoreStandardErrorWarningFormat="true" />
38+
39+
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)" /nologo /silent'
40+
Condition = " Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND (!Exists('$(TargetPath).config') OR '$(OutputType)' != 'Exe') AND '$(IsAdministrator)' == 'true' "
41+
ConsoleToMSBuild="true"
42+
IgnoreStandardErrorWarningFormat="true"/>
43+
44+
<Exec Command='"$(PathToNGen64)" install "$(TargetPath)" /nologo /silent /ExeConfig:$(TargetPath)'
45+
Condition = "Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND Exists('$(TargetPath).config') AND '$(OutputType)' == 'Exe' AND '$(IsAdministrator)' == 'true'"
46+
ConsoleToMSBuild="true"
47+
IgnoreStandardErrorWarningFormat="true" />
48+
49+
<Exec Command='"$(PathToNGen64)" install "$(TargetPath)" /nologo /silent'
50+
Condition = " Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND (!Exists('$(TargetPath).config') OR '$(OutputType)' != 'Exe') AND '$(IsAdministrator)' == 'true' "
51+
ConsoleToMSBuild="true"
52+
IgnoreStandardErrorWarningFormat="true"/>
2753

28-
<Exec Command='"$(PathToNGen64)" install "$(TargetPath)" /ExeConfig:$(TargetPath)' Condition = "Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND Exists('$(TargetPath).config') AND '$(IsAdministrator)' == 'true'"/>
29-
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)" /ExeConfig:$(TargetPath)' Condition = "Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND Exists('$(TargetPath).config') AND '$(IsAdministrator)' == 'true'"/>
30-
<Exec Command='"$(PathToNGen64)" install "$(TargetPath)"' Condition = " Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND (!Exists('$(TargetPath).config')) AND '$(IsAdministrator)' == 'true' "/>
31-
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)"' Condition = " Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND (!Exists('$(TargetPath).config')) AND '$(IsAdministrator)' == 'true' "/>
3254
</Target>
33-
</Project>
55+
56+
<Target Name="SetSkipVerification"
57+
BeforeTargets="NGenWindowsBinaries"
58+
AfterTargets="CopyFilesToOutputDirectory"
59+
Condition="'$(OS)' != 'Unix' AND '$(IsAdministrator)' == 'true' AND '$(AssemblyOriginatorKeyFile)' != '' AND Exists('$(TargetPath)') ">
60+
61+
<PropertyGroup>
62+
<PathToSN32>$(WindowsSDK_ExecutablePath_x86)\sn.exe</PathToSN32>
63+
<PathToSN64>$(WindowsSDK_ExecutablePath_x64)\sn.exe</PathToSN64>
64+
</PropertyGroup>
65+
66+
<Exec Command='"$(PathToSN32)" /q /Vr "$(TargetPath)"' Condition = "Exists('$(PathToSN32)') AND '$(DelaySign)' == 'true' AND Exists('$(TargetPath)') AND '$(IsAdministrator)' == 'true'" ConsoleToMsBuild='true' />
67+
<Exec Command='"$(PathToSN64)" /q /Vr "$(TargetPath)"' Condition = "Exists('$(PathToSN64)') AND '$(DelaySign)' == 'true' AND Exists('$(TargetPath)') AND '$(IsAdministrator)' == 'true'" ConsoleToMsBuild='true' />
68+
</Target>
69+
70+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11

2+
warning FS0082: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. (Code=MSB3270)
3+
4+
warning FS0082: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Data.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. (Code=MSB3270)
5+
6+
warning FS0082: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Web.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. (Code=MSB3270)
7+
8+
warning FS0082: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. (Code=MSB3270)
9+
10+
warning FS0082: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Data.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. (Code=MSB3270)
11+
12+
warning FS0082: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Web.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. (Code=MSB3270)
13+
214
test.fs(7,17): warning FS0864: This new member hides the abstract member 'abstract member Base.Foo : unit -> unit'. Rename the member or use 'override' instead.

0 commit comments

Comments
 (0)