Skip to content

Commit 90db61b

Browse files
KevinRansombaronfel
authored andcommitted
fixes issue #6832 (#7259)
* fixes issue #6832 * Fix comment * Forgot to remove pdbs from fsharp.compiler.nuget * Rename Program.fs and exclude FSharpSdk from checks * Embedded doesn't need to verify tmp or obj directories. * typo * typo * Don't check FSharpSdk for hash * Make comment match code * Empty commit to force rebuild
1 parent e4ef1e1 commit 90db61b

File tree

7 files changed

+83
-20
lines changed

7 files changed

+83
-20
lines changed

FSharpBuild.Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<RepositoryUrl Condition="'$(RepositoryUrl)' == ''">https://github.com/Microsoft/visualfsharp</RepositoryUrl>
7676
<RepositoryType Condition="'$(RepositoryType)' == ''">git</RepositoryType>
7777
</PropertyGroup>
78+
7879
<PropertyGroup Condition="'$(FSharpSourceBuild)' == 'true' AND '$(RepositoryCommit)' == ''">
7980
<_DotGitDir>$(RepoRoot).git</_DotGitDir>
8081
<_HeadFileContent Condition="Exists('$(_DotGitDir)/HEAD')">$([System.IO.File]::ReadAllText('$(_DotGitDir)/HEAD').Trim())</_HeadFileContent>
@@ -87,7 +88,7 @@
8788
<PropertyGroup>
8889
<NoWarn Condition="'$(Language)' == 'F#'">$(NoWarn);FS2003</NoWarn><!-- warning when AssemblyInformationalVersion looks like '1.2.3-dev' -->
8990
<NoCompilerStandardLib>true</NoCompilerStandardLib><!-- necessary for resource generation using csc.exe -->
90-
<DebugType>portable</DebugType>
91+
<DebugType>embedded</DebugType>
9192
<MicroBuildAssemblyFileLanguage>fs</MicroBuildAssemblyFileLanguage>
9293
<UseStandardResourceNames>false</UseStandardResourceNames>
9394
<GenerateDocumentationFile>true</GenerateDocumentationFile>

eng/Build.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,14 @@ function UpdatePath() {
211211
TestAndAddToPath "$ArtifactsDir\bin\fsiAnyCpu\$configuration\net472"
212212
}
213213

214-
function VerifyAssemblyVersions() {
215-
$fsiPath = Join-Path $ArtifactsDir "bin\fsi\Proto\net472\publish\fsi.exe"
214+
function VerifyAssemblyVersionsAndSymbols() {
215+
$assemblyVerCheckPath = Join-Path $ArtifactsDir "Bootstrap\AssemblyCheck\AssemblyCheck.dll"
216216

217217
# Only verify versions on CI or official build
218218
if ($ci -or $official) {
219-
$asmVerCheckPath = "$RepoRoot\scripts"
220-
Exec-Console $fsiPath """$asmVerCheckPath\AssemblyVersionCheck.fsx"" -- ""$ArtifactsDir"""
219+
$dotnetPath = InitializeDotNetCli
220+
$dotnetExe = Join-Path $dotnetPath "dotnet.exe"
221+
Exec-Console $dotnetExe """$assemblyVerCheckPath"" ""$ArtifactsDir"""
221222
}
222223
}
223224

@@ -263,7 +264,7 @@ try {
263264
}
264265

265266
if ($build) {
266-
VerifyAssemblyVersions
267+
VerifyAssemblyVersionsAndSymbols
267268
}
268269

269270
$desktopTargetFramework = "net472"

eng/build-utils.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,11 @@ function Make-BootstrapBuild() {
236236
Remove-Item -re $dir -ErrorAction SilentlyContinue
237237
Create-Directory $dir
238238

239-
# prepare FsLex and Fsyacc
239+
# prepare FsLex and Fsyacc and AssemblyCheck
240240
Run-MSBuild "$RepoRoot\src\buildtools\buildtools.proj" "/restore /t:Publish" -logFileName "BuildTools" -configuration $bootstrapConfiguration
241241
Copy-Item "$ArtifactsDir\bin\fslex\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\fslex" -Force -Recurse
242242
Copy-Item "$ArtifactsDir\bin\fsyacc\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\fsyacc" -Force -Recurse
243+
Copy-Item "$ArtifactsDir\bin\AssemblyCheck\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\AssemblyCheck" -Force -Recurse
243244

244245
# prepare compiler
245246
$projectPath = "$RepoRoot\proto.proj"

src/absil/ilwritepdb.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ let pdbGetEmbeddedPdbDebugInfo (embeddedPdbChunk: BinaryChunk) (uncompressedLeng
186186
Buffer.BlockCopy(stream.ToArray(), 0, buffer, offset, size)
187187
buffer
188188
{ iddCharacteristics = 0 // Reserved
189-
iddMajorVersion = 0 // VersionMajor should be 0
189+
iddMajorVersion = 0x0100 // VersionMajor should be 0x0100
190190
iddMinorVersion = 0x0100 // VersionMinor should be 0x0100
191191
iddType = 17 // IMAGE_DEBUG_TYPE_EMBEDDEDPDB
192192
iddTimestamp = 0
Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,50 @@
1-
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
22

33
open System
44
open System.Diagnostics
55
open System.IO
66
open System.Reflection
7+
open System.Reflection.PortableExecutable
78
open System.Text.RegularExpressions
89

9-
module AssemblyVersionCheck =
10+
module AssemblyCheck =
1011

1112
let private versionZero = Version(0, 0, 0, 0)
1213
let private versionOne = Version(1, 0, 0, 0)
1314
let private commitHashPattern = new Regex(@"Commit Hash: (<developer build>)|([0-9a-fA-F]{40})", RegexOptions.Compiled)
1415
let private devVersionPattern = new Regex(@"-(ci|dev)", RegexOptions.Compiled)
1516

16-
let verifyAssemblyVersions (binariesPath:string) =
17+
let verifyEmbeddedPdb (filename:string) =
18+
use fileStream = File.OpenRead(filename)
19+
let reader = new PEReader(fileStream)
20+
let mutable hasEmbeddedPdb = false
21+
22+
try
23+
for entry in reader.ReadDebugDirectory() do
24+
match entry.Type with
25+
| DebugDirectoryEntryType.CodeView ->
26+
let _ = reader.ReadCodeViewDebugDirectoryData(entry)
27+
()
28+
29+
| DebugDirectoryEntryType.EmbeddedPortablePdb ->
30+
let _ = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry)
31+
hasEmbeddedPdb <- true
32+
()
33+
34+
| DebugDirectoryEntryType.PdbChecksum ->
35+
let _ = reader.ReadPdbChecksumDebugDirectoryData(entry)
36+
()
37+
38+
| _ -> ()
39+
with | e -> printfn "Error validating assembly %s\nMessage: %s" filename (e.ToString())
40+
hasEmbeddedPdb
41+
42+
let verifyAssemblies (binariesPath:string) =
43+
1744
let excludedAssemblies =
1845
[ "FSharp.Data.TypeProviders.dll" ]
1946
|> Set.ofList
47+
2048
let fsharpAssemblies =
2149
[ "FSharp*.dll"
2250
"fsc.exe"
@@ -28,12 +56,17 @@ module AssemblyVersionCheck =
2856
|> List.ofSeq
2957
|> List.filter (fun p -> (Set.contains (Path.GetFileName(p)) excludedAssemblies) |> not)
3058

59+
let fsharpExecutingWithEmbeddedPdbs =
60+
fsharpAssemblies
61+
|> List.filter (fun p -> not (p.Contains(@"\Proto\") || p.Contains(@"\Bootstrap\") || p.Contains(@".resources.") || p.Contains(@"\FSharpSdk\") || p.Contains(@"\tmp\") || p.Contains(@"\obj\")))
62+
3163
// verify that all assemblies have a version number other than 0.0.0.0 or 1.0.0.0
3264
let failedVersionCheck =
3365
fsharpAssemblies
3466
|> List.filter (fun a ->
3567
let assemblyVersion = AssemblyName.GetAssemblyName(a).Version
3668
assemblyVersion = versionZero || assemblyVersion = versionOne)
69+
3770
if failedVersionCheck.Length > 0 then
3871
printfn "The following assemblies had a version of %A or %A" versionZero versionOne
3972
printfn "%s\r\n" <| String.Join("\r\n", failedVersionCheck)
@@ -43,27 +76,36 @@ module AssemblyVersionCheck =
4376
// verify that all assemblies have a commit hash
4477
let failedCommitHash =
4578
fsharpAssemblies
79+
|> List.filter (fun p -> not (p.Contains(@"\FSharpSdk\")))
4680
|> List.filter (fun a ->
4781
let fileProductVersion = FileVersionInfo.GetVersionInfo(a).ProductVersion
4882
not (commitHashPattern.IsMatch(fileProductVersion) || devVersionPattern.IsMatch(fileProductVersion)))
83+
4984
if failedCommitHash.Length > 0 then
5085
printfn "The following assemblies don't have a commit hash set"
5186
printfn "%s\r\n" <| String.Join("\r\n", failedCommitHash)
5287
else
5388
printfn "All shipping assemblies had an appropriate commit hash."
5489

90+
// verify that all assemblies have an embedded pdb
91+
let failedVerifyEmbeddedPdb =
92+
fsharpExecutingWithEmbeddedPdbs
93+
|> List.filter (fun a -> not (verifyEmbeddedPdb a))
94+
95+
if failedVerifyEmbeddedPdb.Length > 0 then
96+
printfn "The following assemblies don't have an embedded pdb"
97+
printfn "%s\r\n" <| String.Join("\r\n", failedVerifyEmbeddedPdb)
98+
else
99+
printfn "All shipping assemblies had an embedded PDB."
100+
55101
// return code is the number of failures
56-
failedVersionCheck.Length + failedCommitHash.Length
102+
failedVersionCheck.Length + failedCommitHash.Length + failedVerifyEmbeddedPdb.Length
57103

104+
105+
[<EntryPoint>]
58106
let main (argv:string array) =
59107
if argv.Length <> 1 then
60-
printfn "Usage: fsi.exe AssemblyVersionCheck.fsx -- path/to/binaries"
108+
printfn "Usage: dotnet AssemblyCheck.dll -- path/to/binaries"
61109
1
62110
else
63-
AssemblyVersionCheck.verifyAssemblyVersions argv.[0]
64-
65-
Environment.GetCommandLineArgs()
66-
|> Seq.skipWhile ((<>) "--")
67-
|> Seq.skip 1
68-
|> Array.ofSeq
69-
|> main
111+
AssemblyCheck.verifyAssemblies argv.[0]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Compile Include="AssemblyCheck.fs" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\fsharp\FSharp.Core\FSharp.Core.fsproj" />
15+
</ItemGroup>
16+
17+
</Project>

src/buildtools/buildtools.proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ItemGroup>
99
<Projects Include="fslex\fslex.fsproj" />
1010
<Projects Include="fsyacc\fsyacc.fsproj" />
11+
<Projects Include="AssemblyCheck\AssemblyCheck.fsproj" />
1112
</ItemGroup>
1213

1314
<Target Name="Build">

0 commit comments

Comments
 (0)