diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props
index 515de9bbdc7..6687fb40888 100644
--- a/FSharpBuild.Directory.Build.props
+++ b/FSharpBuild.Directory.Build.props
@@ -75,6 +75,7 @@
https://github.com/Microsoft/visualfsharp
git
+
<_DotGitDir>$(RepoRoot).git
<_HeadFileContent Condition="Exists('$(_DotGitDir)/HEAD')">$([System.IO.File]::ReadAllText('$(_DotGitDir)/HEAD').Trim())
@@ -87,7 +88,7 @@
$(NoWarn);FS2003
true
- portable
+ embedded
fs
false
true
diff --git a/eng/Build.ps1 b/eng/Build.ps1
index f329cba02ac..8011827a643 100644
--- a/eng/Build.ps1
+++ b/eng/Build.ps1
@@ -224,13 +224,14 @@ function UpdatePath() {
TestAndAddToPath "$ArtifactsDir\bin\fsiAnyCpu\$configuration\net472"
}
-function VerifyAssemblyVersions() {
- $fsiPath = Join-Path $ArtifactsDir "bin\fsi\Proto\net472\publish\fsi.exe"
+function VerifyAssemblyVersionsAndSymbols() {
+ $assemblyVerCheckPath = Join-Path $ArtifactsDir "Bootstrap\AssemblyCheck\AssemblyCheck.dll"
# Only verify versions on CI or official build
if ($ci -or $official) {
- $asmVerCheckPath = "$RepoRoot\scripts"
- Exec-Console $fsiPath """$asmVerCheckPath\AssemblyVersionCheck.fsx"" -- ""$ArtifactsDir"""
+ $dotnetPath = InitializeDotNetCli
+ $dotnetExe = Join-Path $dotnetPath "dotnet.exe"
+ Exec-Console $dotnetExe """$assemblyVerCheckPath"" ""$ArtifactsDir"""
}
}
@@ -307,7 +308,7 @@ try {
}
if ($build) {
- VerifyAssemblyVersions
+ VerifyAssemblyVersionsAndSymbols
}
$desktopTargetFramework = "net472"
diff --git a/eng/build-utils.ps1 b/eng/build-utils.ps1
index fcda1a58e26..772de110ca2 100644
--- a/eng/build-utils.ps1
+++ b/eng/build-utils.ps1
@@ -236,10 +236,11 @@ function Make-BootstrapBuild() {
Remove-Item -re $dir -ErrorAction SilentlyContinue
Create-Directory $dir
- # prepare FsLex and Fsyacc
+ # prepare FsLex and Fsyacc and AssemblyCheck
Run-MSBuild "$RepoRoot\src\buildtools\buildtools.proj" "/restore /t:Publish" -logFileName "BuildTools" -configuration $bootstrapConfiguration
Copy-Item "$ArtifactsDir\bin\fslex\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\fslex" -Force -Recurse
Copy-Item "$ArtifactsDir\bin\fsyacc\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\fsyacc" -Force -Recurse
+ Copy-Item "$ArtifactsDir\bin\AssemblyCheck\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\AssemblyCheck" -Force -Recurse
# prepare compiler
$projectPath = "$RepoRoot\proto.proj"
diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs
index c1ffd692249..86b7ee9224f 100644
--- a/src/absil/ilwritepdb.fs
+++ b/src/absil/ilwritepdb.fs
@@ -186,7 +186,7 @@ let pdbGetEmbeddedPdbDebugInfo (embeddedPdbChunk: BinaryChunk) (uncompressedLeng
Buffer.BlockCopy(stream.ToArray(), 0, buffer, offset, size)
buffer
{ iddCharacteristics = 0 // Reserved
- iddMajorVersion = 0 // VersionMajor should be 0
+ iddMajorVersion = 0x0100 // VersionMajor should be 0x0100
iddMinorVersion = 0x0100 // VersionMinor should be 0x0100
iddType = 17 // IMAGE_DEBUG_TYPE_EMBEDDEDPDB
iddTimestamp = 0
diff --git a/scripts/AssemblyVersionCheck.fsx b/src/buildtools/AssemblyCheck/AssemblyCheck.fs
similarity index 51%
rename from scripts/AssemblyVersionCheck.fsx
rename to src/buildtools/AssemblyCheck/AssemblyCheck.fs
index 0f3816a2e6c..c6bd035a673 100644
--- a/scripts/AssemblyVersionCheck.fsx
+++ b/src/buildtools/AssemblyCheck/AssemblyCheck.fs
@@ -1,22 +1,50 @@
-// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
open System
open System.Diagnostics
open System.IO
open System.Reflection
+open System.Reflection.PortableExecutable
open System.Text.RegularExpressions
-module AssemblyVersionCheck =
+module AssemblyCheck =
let private versionZero = Version(0, 0, 0, 0)
let private versionOne = Version(1, 0, 0, 0)
let private commitHashPattern = new Regex(@"Commit Hash: ()|([0-9a-fA-F]{40})", RegexOptions.Compiled)
let private devVersionPattern = new Regex(@"-(ci|dev)", RegexOptions.Compiled)
- let verifyAssemblyVersions (binariesPath:string) =
+ let verifyEmbeddedPdb (filename:string) =
+ use fileStream = File.OpenRead(filename)
+ let reader = new PEReader(fileStream)
+ let mutable hasEmbeddedPdb = false
+
+ try
+ for entry in reader.ReadDebugDirectory() do
+ match entry.Type with
+ | DebugDirectoryEntryType.CodeView ->
+ let _ = reader.ReadCodeViewDebugDirectoryData(entry)
+ ()
+
+ | DebugDirectoryEntryType.EmbeddedPortablePdb ->
+ let _ = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry)
+ hasEmbeddedPdb <- true
+ ()
+
+ | DebugDirectoryEntryType.PdbChecksum ->
+ let _ = reader.ReadPdbChecksumDebugDirectoryData(entry)
+ ()
+
+ | _ -> ()
+ with | e -> printfn "Error validating assembly %s\nMessage: %s" filename (e.ToString())
+ hasEmbeddedPdb
+
+ let verifyAssemblies (binariesPath:string) =
+
let excludedAssemblies =
[ "FSharp.Data.TypeProviders.dll" ]
|> Set.ofList
+
let fsharpAssemblies =
[ "FSharp*.dll"
"fsc.exe"
@@ -28,12 +56,17 @@ module AssemblyVersionCheck =
|> List.ofSeq
|> List.filter (fun p -> (Set.contains (Path.GetFileName(p)) excludedAssemblies) |> not)
+ let fsharpExecutingWithEmbeddedPdbs =
+ fsharpAssemblies
+ |> List.filter (fun p -> not (p.Contains(@"\Proto\") || p.Contains(@"\Bootstrap\") || p.Contains(@".resources.") || p.Contains(@"\FSharpSdk\") || p.Contains(@"\tmp\") || p.Contains(@"\obj\")))
+
// verify that all assemblies have a version number other than 0.0.0.0 or 1.0.0.0
let failedVersionCheck =
fsharpAssemblies
|> List.filter (fun a ->
let assemblyVersion = AssemblyName.GetAssemblyName(a).Version
assemblyVersion = versionZero || assemblyVersion = versionOne)
+
if failedVersionCheck.Length > 0 then
printfn "The following assemblies had a version of %A or %A" versionZero versionOne
printfn "%s\r\n" <| String.Join("\r\n", failedVersionCheck)
@@ -43,27 +76,36 @@ module AssemblyVersionCheck =
// verify that all assemblies have a commit hash
let failedCommitHash =
fsharpAssemblies
+ |> List.filter (fun p -> not (p.Contains(@"\FSharpSdk\")))
|> List.filter (fun a ->
let fileProductVersion = FileVersionInfo.GetVersionInfo(a).ProductVersion
not (commitHashPattern.IsMatch(fileProductVersion) || devVersionPattern.IsMatch(fileProductVersion)))
+
if failedCommitHash.Length > 0 then
printfn "The following assemblies don't have a commit hash set"
printfn "%s\r\n" <| String.Join("\r\n", failedCommitHash)
else
printfn "All shipping assemblies had an appropriate commit hash."
+ // verify that all assemblies have an embedded pdb
+ let failedVerifyEmbeddedPdb =
+ fsharpExecutingWithEmbeddedPdbs
+ |> List.filter (fun a -> not (verifyEmbeddedPdb a))
+
+ if failedVerifyEmbeddedPdb.Length > 0 then
+ printfn "The following assemblies don't have an embedded pdb"
+ printfn "%s\r\n" <| String.Join("\r\n", failedVerifyEmbeddedPdb)
+ else
+ printfn "All shipping assemblies had an embedded PDB."
+
// return code is the number of failures
- failedVersionCheck.Length + failedCommitHash.Length
+ failedVersionCheck.Length + failedCommitHash.Length + failedVerifyEmbeddedPdb.Length
+
+[]
let main (argv:string array) =
if argv.Length <> 1 then
- printfn "Usage: fsi.exe AssemblyVersionCheck.fsx -- path/to/binaries"
+ printfn "Usage: dotnet AssemblyCheck.dll -- path/to/binaries"
1
else
- AssemblyVersionCheck.verifyAssemblyVersions argv.[0]
-
-Environment.GetCommandLineArgs()
-|> Seq.skipWhile ((<>) "--")
-|> Seq.skip 1
-|> Array.ofSeq
-|> main
+ AssemblyCheck.verifyAssemblies argv.[0]
diff --git a/src/buildtools/AssemblyCheck/AssemblyCheck.fsproj b/src/buildtools/AssemblyCheck/AssemblyCheck.fsproj
new file mode 100644
index 00000000000..72f79d02f93
--- /dev/null
+++ b/src/buildtools/AssemblyCheck/AssemblyCheck.fsproj
@@ -0,0 +1,17 @@
+
+
+
+ Exe
+ netcoreapp2.1
+ true
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/buildtools/buildtools.proj b/src/buildtools/buildtools.proj
index 630bb678561..7ac48ba2a37 100644
--- a/src/buildtools/buildtools.proj
+++ b/src/buildtools/buildtools.proj
@@ -8,6 +8,7 @@
+
diff --git a/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec b/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec
index d3756ebc392..a82fbb1ac3e 100644
--- a/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec
+++ b/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec
@@ -49,15 +49,7 @@
-
-
-
-
-
-
-
+ target="lib\netcoreapp2.1" />
@@ -69,9 +61,9 @@
+ target="lib\netcoreapp2.1" />
+ target="lib\netcoreapp2.1" />
diff --git a/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec b/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec
index 750052c45db..ee7a88b29d6 100644
--- a/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec
+++ b/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec
@@ -38,13 +38,11 @@
-
-