提交 5a3d00de 编写于 作者: T Tomáš Matoušek 提交者: GitHub

Stop generating LanguageServiceRegistrationFiles (#14256)

上级 183e50f8
...@@ -793,37 +793,20 @@ Public Class BuildDevDivInsertionFiles ...@@ -793,37 +793,20 @@ Public Class BuildDevDivInsertionFiles
Continue For Continue For
End If End If
If dependencies.ContainsKey(partFileName) Then If IsLanguageServiceRegistrationFile(partFileName) Then
Continue For Continue For
End If End If
Dim relativeOutputDir As String If dependencies.ContainsKey(partFileName) Then
If IsLanguageServiceRegistrationFile(partFileName) Then Continue For
relativeOutputDir = Path.Combine(GetExternalApiDirectory(), "LanguageServiceRegistration", vsixName)
Else
relativeOutputDir = GetExternalApiDirectory()
End If End If
Dim relativeOutputFilePath = Path.Combine(relativeOutputDir, partFileName) Dim relativeOutputFilePath = Path.Combine(GetExternalApiDirectory(), partFileName)
If processedFiles.Add(relativeOutputFilePath) Then If processedFiles.Add(relativeOutputFilePath) Then
If IsLanguageServiceRegistrationFile(partFileName) Then ' paths are relative to input directory:
Dim absoluteOutputFilePath = GetAbsolutePathInOutputDirectory(relativeOutputFilePath) filesToInsert.Add(New NugetFileInfo(partFileName))
WriteVsixPartToFile(vsixPart, absoluteOutputFilePath) AddXmlDocumentationFile(filesToInsert, partFileName)
' We want to rewrite a few of these things from our standard vsix-installable forms
Select Case Path.GetExtension(absoluteOutputFilePath)
Case ".pkgdef"
RewritePkgDef(absoluteOutputFilePath)
Case ".vsixmanifest"
RewriteVsixManifest(absoluteOutputFilePath)
End Select
Else
' paths are relative to input directory:
filesToInsert.Add(New NugetFileInfo(partFileName))
AddXmlDocumentationFile(filesToInsert, partFileName)
End If
End If End If
Next Next
End Using End Using
...@@ -850,12 +833,6 @@ Public Class BuildDevDivInsertionFiles ...@@ -850,12 +833,6 @@ Public Class BuildDevDivInsertionFiles
End If End If
End Sub End Sub
Private Sub WriteVsixPartToFile(vsixPart As PackagePart, path As String)
Using outputStream = New FileStream(path, FileMode.Create)
vsixPart.GetStream().CopyTo(outputStream)
End Using
End Sub
''' <summary> ''' <summary>
''' Takes a list of paths relative to <see cref="_outputDirectory"/> and generates a nuspec file that includes them. ''' Takes a list of paths relative to <see cref="_outputDirectory"/> and generates a nuspec file that includes them.
''' </summary> ''' </summary>
...@@ -872,7 +849,6 @@ Public Class BuildDevDivInsertionFiles ...@@ -872,7 +849,6 @@ Public Class BuildDevDivInsertionFiles
<version>0.0</version> <version>0.0</version>
</metadata> </metadata>
<files> <files>
<file src=<%= Path.Combine(DevDivInsertionFilesDirName, ExternalApisDirName, "Roslyn", "**") %> target=""/>
<%= filesToInsert. <%= filesToInsert.
OrderBy(Function(f) f.Path). OrderBy(Function(f) f.Path).
Distinct(). Distinct().
...@@ -883,33 +859,6 @@ Public Class BuildDevDivInsertionFiles ...@@ -883,33 +859,6 @@ Public Class BuildDevDivInsertionFiles
xml.Save(GetAbsolutePathInOutputDirectory(PackageName & ".nuspec"), SaveOptions.OmitDuplicateNamespaces) xml.Save(GetAbsolutePathInOutputDirectory(PackageName & ".nuspec"), SaveOptions.OmitDuplicateNamespaces)
End Sub End Sub
Private Sub RewriteVsixManifest(fileToRewrite As String)
Dim xml = XDocument.Load(fileToRewrite)
Dim installationElement = xml.<vsix:PackageManifest>.<vsix:Installation>.Single()
' We want to modify the .vsixmanifest to say this was installed via MSI
installationElement.@InstalledByMsi = "true"
' Ensure the VSIX isn't shown in the extension gallery
installationElement.@SystemComponent = "true"
' We build our VSIXes with the experimental flag so you can install them as test extensions. In the real MSI, they're not experimental.
installationElement.Attribute("Experimental")?.Remove()
' Update the path to our MEF/Analyzer Components to be in their new home under PrivateAssemblies
Dim assets = From asset In xml...<vsix:Asset>
Where asset.@Type = "Microsoft.VisualStudio.MefComponent" OrElse
asset.@Type = "Microsoft.VisualStudio.Analyzer"
For Each asset In assets
asset.@Path = "$RootFolder$Common7\IDE\PrivateAssemblies\" & asset.@Path
Next
xml.Save(fileToRewrite)
End Sub
Private Shared Function IsVisualStudioLanguageServiceComponent(fileName As String) As Boolean
Return fileName.StartsWith("Microsoft.VisualStudio.LanguageServices.")
End Function
Private Sub GenerateRoslynCompilerNuSpec(filesToInsert As IEnumerable(Of String)) Private Sub GenerateRoslynCompilerNuSpec(filesToInsert As IEnumerable(Of String))
Const PackageName As String = "VS.Tools.Roslyn" Const PackageName As String = "VS.Tools.Roslyn"
...@@ -973,69 +922,4 @@ set DEVPATH=%RoslynToolsRoot%;%DEVPATH%" ...@@ -973,69 +922,4 @@ set DEVPATH=%RoslynToolsRoot%;%DEVPATH%"
Return absolutePath Return absolutePath
End Function End Function
''' <summary>
''' Rewrites a .pkgdef file to load any packages from PrivateAssemblies instead of from the .vsix's folder. This allows
''' for better use of ngen'ed images when we are installed into VS.
''' </summary>
Private Sub RewritePkgDef(fileToRewrite As String)
' Our VSIXes normally contain a number of CodeBase attributes in our .pkgdefs so Visual Studio knows where
' to load assemblies. These come in one of two forms:
'
' 1) as a part of a binding redirection:
'
' [$RootKey$\RuntimeConfiguration\dependentAssembly\bindingRedirection\{A907DD23-73A7-8934-9396-93F10C532071}]
' "name"="System.Reflection.Metadata"
' "publicKeyToken"="b03f5f7f11d50a3a"
' "culture"="neutral"
' "oldVersion"="1.0.0.0-1.0.99.0"
' "newVersion"="1.1.0.0"
' "codeBase"="$PackageFolder$\System.Reflection.Metadata.dll"
'
' 2) as part of a codebase-only specification without a binding redirect:
'
' [$RootKey$\RuntimeConfiguration\dependentAssembly\codeBase\{8C6E3F81-ED3F-306B-107F-60D6E74DA5B0}]
' "name"="Esent.Interop"
' "publicKeyToken"="31bf3856ad364e35"
' "culture"="neutral"
' "version"="1.9.2.0"
' "codeBase"="$PackageFolder$\Esent.Interop.dll"
'
' Each of these use $PackageFolder$ as a way to specify the VSIX-relative path. When we convert our VSIXes
' to be installed as MSIs, we don't want the DLLs in the CommonExtensions next to our .pkgdefs. Instead
' we want them in PrivateAssemblies so they're in the loading path to enable proper ngen. Thus, these CodeBase
' attributes have to go. For #1, we can just delete the codeBase key, and leave the rest of the redirection
' in place. For #2, we can delete the entire section.
Dim lines = File.ReadAllLines(fileToRewrite)
Dim inBindingRedirect = False
Dim inCodebase = False
For i = 0 To lines.Count - 1
Dim line = lines(i)
If line.StartsWith("[") Then
inBindingRedirect = line.IndexOf("bindingRedirection", StringComparison.OrdinalIgnoreCase) >= 0
inCodebase = line.IndexOf("RuntimeConfiguration\dependentAssembly\codeBase", StringComparison.OrdinalIgnoreCase) >= 0
End If
Dim parts = line.Split({"="c}, count:=2)
If inCodebase Then
' Explicit codebase attributes must always be dropped
lines(i) = Nothing
ElseIf String.Equals(parts(0), """CodeBase""", StringComparison.OrdinalIgnoreCase) Then
If inBindingRedirect Then
' Drop CodeBase from all binding redirects -- they're only for VSIX installs
lines(i) = Nothing
End If
ElseIf String.Equals(parts(0), """isPkgDefOverrideEnabled""", StringComparison.OrdinalIgnoreCase) Then
' We always need to drop this, since this is only for experimental VSIXes
lines(i) = Nothing
End If
Next
File.WriteAllLines(fileToRewrite, lines.Where(Function(l) l IsNot Nothing))
End Sub
End Class End Class
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册