Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FSharpBuild.Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="eng\targets\Imports.targets" />
<Import Project="eng\targets\NGenBinaries.targets" />
<Import Project="eng\targets\NuGet.targets" />
<Import Project="FSharp.Profiles.props" />

Expand Down
106 changes: 105 additions & 1 deletion eng/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,17 @@ function BuildCompiler() {
$argNoRestore = if ($norestore) { " --no-restore" } else { "" }
$argNoIncremental = if ($rebuild) { " --no-incremental" } else { "" }

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

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

function DownloadDotnetFrameworkSdk() {
$dlTempPath = [System.IO.Path]::GetTempPath()
$dlRandomFile = [System.IO.Path]::GetRandomFileName()
$net48Dir = Join-Path $dlTempPath $dlRandomFile
Create-Directory $net48Dir

$net48Exe = Join-Path $net48Dir "ndp48-devpack-enu.exe"
$dlLogFilePath = Join-Path $LogDir "dotnet48.install.log"
Invoke-WebRequest "https://go.microsoft.com/fwlink/?linkid=2088517" -OutFile $net48Exe

Write-Host "Exec-Console $net48Exe /install /quiet /norestart /log $dlLogFilePath"
Exec-Console $net48Exe "/install /quiet /norestart /log $dlLogFilePath"
}

function Test-IsAdmin {
([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
}

function TryDownloadDotnetFrameworkSdk() {
# If we are not running as admin user, don't bother grabbing ndp sdk -- since we don't need sn.exe
$isAdmin = Test-IsAdmin
Write-Host "TryDownloadDotnetFrameworkSdk -- Test-IsAdmin = '$isAdmin'"
if ($isAdmin -eq $true)
{
# Get program files(x86) location
if (${env:ProgramFiles(x86)} -eq $null) {
$programFiles = $env:ProgramFiles
}
else {
$programFiles = ${env:ProgramFiles(x86)}
}

# Get windowsSDK location for x86
$windowsSDK_ExecutablePath_x86 = $env:WindowsSDK_ExecutablePath_x86
$newWindowsSDK_ExecutablePath_x86 = Join-Path "$programFiles" "Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools"

if ($windowsSDK_ExecutablePath_x86 -eq $null) {
$snPathX86 = Join-Path $newWindowsSDK_ExecutablePath_x86 "sn.exe"
}
else {
$snPathX86 = Join-Path $windowsSDK_ExecutablePath_x86 "sn.exe"
$snPathX86Exists = Test-Path $snPathX86 -PathType Leaf
if ($snPathX86Exists -ne $true) {
$windowsSDK_ExecutablePath_x86 = null
$snPathX86 = Join-Path $newWindowsSDK_ExecutablePath_x86 "sn.exe"
}
}

$windowsSDK_ExecutablePath_x64 = $env:WindowsSDK_ExecutablePath_x64
$newWindowsSDK_ExecutablePath_x64 = Join-Path "$programFiles" "Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64"

if ($windowsSDK_ExecutablePath_x64 -eq $null) {
$snPathX64 = Join-Path $newWindowsSDK_ExecutablePath_x64 "sn.exe"
}
else {
$snPathX64 = Join-Path $windowsSDK_ExecutablePath_x64 "sn.exe"
$snPathX64Exists = Test-Path $snPathX64 -PathType Leaf
if ($snPathX64Exists -ne $true) {
$windowsSDK_ExecutablePath_x86 = null
$snPathX64 = Join-Path $newWindowsSDK_ExecutablePath_x64 "sn.exe"
}
}

$snPathX86Exists = Test-Path $snPathX86 -PathType Leaf
Write-Host "pre-dl snPathX86Exists : $snPathX86Exists - '$snPathX86'"
if ($snPathX86Exists -ne $true) {
DownloadDotnetFrameworkSdk
}

$snPathX86Exists = Test-Path $snPathX86 -PathType Leaf
if ($snPathX86Exists -eq $true) {
if ($windowsSDK_ExecutablePath_x86 -ne $newWindowsSDK_ExecutablePath_x86) {
$windowsSDK_ExecutablePath_x86 = $newWindowsSDK_ExecutablePath_x86
# x86 environment variable
Write-Host "set WindowsSDK_ExecutablePath_x86=$WindowsSDK_ExecutablePath_x86"
[System.Environment]::SetEnvironmentVariable("WindowsSDK_ExecutablePath_x86","$newWindowsSDK_ExecutablePath_x86",[System.EnvironmentVariableTarget]::Machine)
$env:WindowsSDK_ExecutablePath_x86 = $newWindowsSDK_ExecutablePath_x86
}
}

# Also update environment variable for x64
$snPathX64Exists = Test-Path $snPathX64 -PathType Leaf
if ($snPathX64Exists -eq $true) {
if ($windowsSDK_ExecutablePath_x64 -ne $newWindowsSDK_ExecutablePath_x64) {
$windowsSDK_ExecutablePath_x64 = $newWindowsSDK_ExecutablePath_x64
# x64 environment variable
Write-Host "set WindowsSDK_ExecutablePath_x64=$WindowsSDK_ExecutablePath_x64"
[System.Environment]::SetEnvironmentVariable("WindowsSDK_ExecutablePath_x64","$newWindowsSDK_ExecutablePath_x64",[System.EnvironmentVariableTarget]::Machine)
$env:WindowsSDK_ExecutablePath_x64 = $newWindowsSDK_ExecutablePath_x64
}
}
}
}

function EnablePreviewSdks() {
if (Test-Path variable:global:_MSBuildExe) {
return
Expand Down Expand Up @@ -322,9 +424,11 @@ try {
EnablePreviewSdks
}

$buildTool = InitializeBuildTool
$toolsetBuildProj = InitializeToolset
TryDownloadDotnetFrameworkSdk
if ($bootstrap) {
$script:BuildMessage = "Failure building bootstrap compiler"
$toolsetBuildProj = InitializeToolset
$bootstrapDir = Make-BootstrapBuild
}

Expand Down
8 changes: 8 additions & 0 deletions eng/build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ function Make-BootstrapBuild() {
$argNoIncremental = if ($rebuild) { " --no-incremental" } else { "" }

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

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

Copy-Item "$ArtifactsDir\bin\fsc\$bootstrapConfiguration\$bootstrapTfm" -Destination "$dir\fsc" -Force -Recurse
Expand Down
2 changes: 1 addition & 1 deletion eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
if (Test-Path variable:global:_MSBuildExe) {
return $global:_MSBuildExe
}

if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }
$vsMinVersionStr = if ($vsRequirements.version) { $vsRequirements.version } else { "15.9" }
$vsMinVersion = [Version]::new($vsMinVersionStr)
Expand Down Expand Up @@ -579,6 +578,7 @@ function MSBuild-Core() {
}
}

Write-Host "$buildTool.Path: $buildTool.Path --- $cmdArgs"
$exitCode = Exec-Process $buildTool.Path $cmdArgs

if ($exitCode -ne 0) {
Expand Down
83 changes: 60 additions & 23 deletions eng/targets/NGenBinaries.targets
Original file line number Diff line number Diff line change
@@ -1,33 +1,70 @@
<Project>

<!-- Windows permissions means that users can't even see the directory $(SystemRoot)System32\config -->
<PropertyGroup Condition="'$(OS)' != 'Unix' AND Exists('$(SystemRoot)\System32\config\system')">
<IsAdministrator>true</IsAdministrator>
<DelaySign>true</DelaySign>
<PublicSign>false</PublicSign>
</PropertyGroup>
<Target Name="SetIsAdministrator" Condition="'$(OS)' != 'Unix'"
BeforeTargets="MaybeSetSigning">
<Exec Command="net session &gt;nul 2&gt;&amp;1" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<PropertyGroup>
<IsAdministrator Condition="'$(ErrorCode)' != '0'">false</IsAdministrator>
<IsAdministrator Condition="'$(ErrorCode)' == '0'">true</IsAdministrator>
</PropertyGroup>
</Target>

<Target Name="MaybeSetSigning"
BeforeTargets="CoreCompile"
AfterTargets="BeforeCoreCompile"
Condition="'$(OS)' != 'Unix'">

<PropertyGroup Condition="'$(IsAdministrator)' == 'true' ">
<DelaySign>true</DelaySign>
<PublicSign>false</PublicSign>
</PropertyGroup>
</Target>

<Target Name="NGenWindowsBinaries"
AfterTargets="AfterBuild"
Condition="'$(OS)' != 'Unix' AND
$(TargetFramework.StartsWith('net4')) AND
'$(NGenBinary)' == 'true' AND
Exists('$(TargetPath)') ">
AfterTargets="Build"
Condition="'$(OS)' != 'Unix' AND $(TargetFramework.StartsWith('net4')) AND '$(NGenBinary)' == 'true' AND '$(IsAdministrator)' == 'true' AND Exists('$(TargetPath)') ">

<PropertyGroup>
<PathToNGen64>$(windir)\Microsoft.NET\Framework64\v4.0.30319\ngen.exe</PathToNGen64>
<PathToNGen32>$(windir)\Microsoft.NET\Framework\v4.0.30319\ngen.exe</PathToNGen32>
<PathToSN32>$(WindowsSDK_ExecutablePath_x86)sn.exe</PathToSN32>
<PathToNGen64>$(windir)\Microsoft.NET\Framework64\v4.0.30319\ngen.exe</PathToNGen64>
</PropertyGroup>

<!--
Enable Skip Verification and then NGen for both 32 and 64 bit product.
If compiling use the app config file, if present.
-->
<Exec Command='"$(PathToSN32)" /Vr "$(TargetPath)"' Condition = "Exists('$(PathToSN32)') AND Exists('$(TargetPath)') AND '$(IsAdministrator)' == 'true'"/>
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)" /nologo /silent /ExeConfig:$(TargetPath)'
Condition = "Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND Exists('$(TargetPath).config') AND '$(OutputType)' == 'Exe' AND '$(IsAdministrator)' == 'true'"
ConsoleToMSBuild="true"
IgnoreStandardErrorWarningFormat="true" />

<Exec Command='"$(PathToNGen32)" install "$(TargetPath)" /nologo /silent'
Condition = " Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND (!Exists('$(TargetPath).config') OR '$(OutputType)' != 'Exe') AND '$(IsAdministrator)' == 'true' "
ConsoleToMSBuild="true"
IgnoreStandardErrorWarningFormat="true"/>

<Exec Command='"$(PathToNGen64)" install "$(TargetPath)" /nologo /silent /ExeConfig:$(TargetPath)'
Condition = "Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND Exists('$(TargetPath).config') AND '$(OutputType)' == 'Exe' AND '$(IsAdministrator)' == 'true'"
ConsoleToMSBuild="true"
IgnoreStandardErrorWarningFormat="true" />

<Exec Command='"$(PathToNGen64)" install "$(TargetPath)" /nologo /silent'
Condition = " Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND (!Exists('$(TargetPath).config') OR '$(OutputType)' != 'Exe') AND '$(IsAdministrator)' == 'true' "
ConsoleToMSBuild="true"
IgnoreStandardErrorWarningFormat="true"/>

<Exec Command='"$(PathToNGen64)" install "$(TargetPath)" /ExeConfig:$(TargetPath)' Condition = "Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND Exists('$(TargetPath).config') AND '$(IsAdministrator)' == 'true'"/>
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)" /ExeConfig:$(TargetPath)' Condition = "Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND Exists('$(TargetPath).config') AND '$(IsAdministrator)' == 'true'"/>
<Exec Command='"$(PathToNGen64)" install "$(TargetPath)"' Condition = " Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND (!Exists('$(TargetPath).config')) AND '$(IsAdministrator)' == 'true' "/>
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)"' Condition = " Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND (!Exists('$(TargetPath).config')) AND '$(IsAdministrator)' == 'true' "/>
</Target>
</Project>

<Target Name="SetSkipVerification"
BeforeTargets="NGenWindowsBinaries"
AfterTargets="CopyFilesToOutputDirectory"
Condition="'$(OS)' != 'Unix' AND '$(IsAdministrator)' == 'true' AND '$(AssemblyOriginatorKeyFile)' != '' AND Exists('$(TargetPath)') ">

<PropertyGroup>
<PathToSN32>$(WindowsSDK_ExecutablePath_x86)\sn.exe</PathToSN32>
<PathToSN64>$(WindowsSDK_ExecutablePath_x64)\sn.exe</PathToSN64>
</PropertyGroup>

<Exec Command='"$(PathToSN32)" /q /Vr "$(TargetPath)"' Condition = "Exists('$(PathToSN32)') AND '$(DelaySign)' == 'true' AND Exists('$(TargetPath)') AND '$(IsAdministrator)' == 'true'" ConsoleToMsBuild='true' />
<Exec Command='"$(PathToSN64)" /q /Vr "$(TargetPath)"' Condition = "Exists('$(PathToSN64)') AND '$(DelaySign)' == 'true' AND Exists('$(TargetPath)') AND '$(IsAdministrator)' == 'true'" ConsoleToMsBuild='true' />
</Target>

</Project>
12 changes: 12 additions & 0 deletions tests/fsharp/regression/5531/compilation.output.test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@

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)

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)

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)

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)

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)

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)

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.