From 5211093c552aeaf14d36892e5bc2cb5d746212d6 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Mon, 27 Nov 2017 20:41:09 -0800 Subject: [PATCH] Sync compiler and vs toolset files This changes the file set used to build the VS toolset to match that of the standard compiler toolset. Simply re-use the file list in the compiler nuspec file here. This actuall found a bug in our current implementation. We were not copying the config file for csi.exe in the VS toolset. --- .../BuildDevDivInsertionFiles.vb | 91 +++++++++++-------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/src/Setup/DevDivInsertionFiles/BuildDevDivInsertionFiles.vb b/src/Setup/DevDivInsertionFiles/BuildDevDivInsertionFiles.vb index 9ff1e4327cc..924c371853c 100644 --- a/src/Setup/DevDivInsertionFiles/BuildDevDivInsertionFiles.vb +++ b/src/Setup/DevDivInsertionFiles/BuildDevDivInsertionFiles.vb @@ -422,14 +422,7 @@ Public Class BuildDevDivInsertionFiles End If Next - ' VS.Tools.Roslyn CoreXT package needs to contain all dependencies. - Dim vsToolsetFiles = CompilerFiles.Concat({ - "System.Collections.Immutable.dll", - "System.Reflection.Metadata.dll", - "Microsoft.DiaSymReader.Native.amd64.dll", - "Microsoft.DiaSymReader.Native.x86.dll"}) - - GenerateVSToolsRoslynCoreXTNuspec(vsToolsetFiles) + GenerateVSToolsRoslynCoreXTNuspec() ' Copy over the files in the NetFX20 subdirectory (identical, except for references and Authenticode signing). ' These are for msvsmon, whose setup authoring is done by the debugger. @@ -1060,51 +1053,52 @@ Public Class BuildDevDivInsertionFiles xml.Save(GetAbsolutePathInOutputDirectory(PackageName & ".nuspec"), SaveOptions.OmitDuplicateNamespaces) End Sub - - Private Sub GenerateVSToolsRoslynCoreXTNuspec(filesToInsert As IEnumerable(Of String)) - Const PackageName As String = "VS.Tools.Roslyn" - - ' No duplicates are allowed - filesToInsert.GroupBy(Function(x) x).All(Function(g) g.Count() = 1) - - Dim outputFolder = GetAbsolutePathInOutputDirectory(PackageName) - - Directory.CreateDirectory(outputFolder) + ''' + ''' Generates the nuspec + supporting file layout for the Roslyn toolset nupkg file. This is the toolset + ''' which will be used during the VS build. This will exactly match the layout of the toolset used + ''' by the Microsoft.Net.Compilers package + some devdiv environment files. + ''' + Private Sub GenerateVSToolsRoslynCoreXTNuspec() + Const packageName As String = "VS.Tools.Roslyn" + Dim outputDir = GetAbsolutePathInOutputDirectory(packageName) + Dim nuspecFiles As New List(Of String) + Directory.CreateDirectory(outputDir) + + ' First copy over all the files from the compilers toolset. + For Each fileRelativePath In GetCompilerToolsetNuspecFiles() + Dim filePath = Path.Combine(_binDirectory, fileRelativePath) + Dim fileName = Path.GetFileName(fileRelativePath) + Dim destFilepath = Path.Combine(_outputDirectory, fileName) + File.Copy(filePath, destFilepath) + nuspecFiles.Add(fileName) + + ' A bug in VS forces all of our exes to use the prefer 32 bit mode. Mark the copies added + ' to this nuspec as such. They are isolated and hence allow our binaries shipped to customers + ' to remain executable as 64 bit apps + ' See https://github.com/dotnet/roslyn/issues/17864 + If Path.GetExtension(fileName) = ".exe" Then + MarkFile32BitPref(destFilepath) + End If + Next ' Write an Init.cmd that sets DEVPATH to the toolset location. This overrides ' assembly loading during the VS build to always look in the Roslyn toolset ' first. This is necessary because there are various incompatible versions ' of Roslyn littered throughout the DEVPATH already and this one should always ' take precedence. + Dim initFileName = "Init.cmd" Dim fileContents = "@echo off set RoslynToolsRoot=%~dp0 set DEVPATH=%RoslynToolsRoot%;%DEVPATH%" - File.WriteAllText( - Path.Combine(outputFolder, "Init.cmd"), - fileContents) - - ' Copy all dependent compiler files to the output directory - ' It is most important to have isolated copies of the compiler - ' exes (csc, vbc, vbcscompiler) since we are going to mark them - ' 32-bit only to work around problems with the VS build. - ' These binaries should never ship anywhere other than the VS toolset - ' See https://github.com/dotnet/roslyn/issues/17864 - For Each fileName In filesToInsert - Dim srcPath = Path.Combine(_binDirectory, GetMappedPath(fileName)) - Dim dstPath = Path.Combine(outputFolder, fileName) - File.Copy(srcPath, dstPath) - - If Path.GetExtension(fileName) = ".exe" Then - MarkFile32BitPref(dstPath) - End If - Next + File.WriteAllText(Path.Combine(outputDir, initFileName), fileContents) + nuspecFiles.Add(initFileName) Dim xml = - <%= PackageName %> + <%= packageName %> Roslyn compiler binaries used to build VS CoreXT package for Roslyn compiler toolset. Managed Language Compilers @@ -1112,13 +1106,13 @@ set DEVPATH=%RoslynToolsRoot%;%DEVPATH%" - <%= filesToInsert. + <%= nuspecFiles. OrderBy(Function(f) f). Select(Function(f) />) %> - xml.Save(Path.Combine(outputFolder, PackageName & ".nuspec"), SaveOptions.OmitDuplicateNamespaces) + xml.Save(Path.Combine(outputDir, packageName & ".nuspec"), SaveOptions.OmitDuplicateNamespaces) End Sub Private Sub MarkFile32BitPref(filePath As String) @@ -1166,4 +1160,21 @@ set DEVPATH=%RoslynToolsRoot%;%DEVPATH%" Return absolutePath End Function + + ''' + ''' Get the list of files that appear in the compiler toolset nuspec file. This is the authorative + ''' list of files that make up the compiler toolset layout. + ''' + Private Function GetCompilerToolsetNuspecFiles() As List(Of String) + Dim files As New List(Of String) + Dim nuspecFilePath = Path.Combine(_nuspecDirectory, "Microsoft.Net.Compilers.nuspec") + Dim document = XDocument.Parse(File.ReadAllText(nuspecFilePath)) + For Each fileElement In document... + If fileElement.Attribute("target").Value = "tools" Then + files.Add(fileElement.Attribute("src").Value) + End If + Next + + Return files + End Function End Class -- GitLab