* Add installer shim for 'Web Site's. Update nupkg authoring with readme's.

* Ship it.
This commit is contained in:
Steve Molloy 2023-06-13 17:44:26 -07:00 коммит произвёл GitHub
Родитель 919235a7c1
Коммит 1b3015a245
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 578 добавлений и 15 удалений

Просмотреть файл

@ -5,10 +5,6 @@
</solution>
<packageSources>
<clear />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<!-- Disables command-line, automatic, and MSBuild-Integrated restore -->
<add key="enabled" value="True" />
</packageRestore>
</configuration>

Двоичные данные
.nuget/NuGet.exe

Двоичный файл не отображается.

Просмотреть файл

@ -6,6 +6,11 @@ for an introduction to Microsoft.CodeDom.Providers.DotNetCompilerPlatform.
## Updates
+ #### Version 4.1.0 (preview1)
- #### :warning: Drop install.ps1, Rely more on msbuild :warning:
Nuget has moved on from install.ps1. We had one foot in the msbuild camp before, and one foot still in the install.ps1 camp. Time to just jump in with both feet. See the 'RoslynRegisterInConfig' setting description below.
<u>**Moving fully to an msbuild/targets-based model will break project-less ASP.Net "Web Sites."**</u> The old install.ps1 way of doing things was becoming less tenable as NuGet continued to evolve. The switch to msbuild/targets was an easy choice. But "Web Site" projects have very limited support in msbuild. We have created a new package that brings back the 'install.ps1' functionality of the 3.X releases _only for WebSites._ It is called [Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites](https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites).
- #### Refreshed current compilers
In keeping with the new versioning scheme for this project, the version has been revved to 4.1 to match the version of the compilers included.
@ -15,9 +20,6 @@ for an introduction to Microsoft.CodeDom.Providers.DotNetCompilerPlatform.
- #### .Net >= 4.7.2
As a result of not keeping older compilers packaged in this project, we can no longer support versions before 4.7.2 because compiler versions 3.0 and newer only support 4.7.2+.
- #### Drop install.ps1, Rely more on msbuild
Nuget has moved on from install.ps1. We had one foot in the msbuild camp before, and one foot still in the install.ps1 camp. Time to just jump in with both feet. See the 'RoslynRegisterInConfig' setting description below.
+ #### Version 3.11.0 (preview1)
- #### Refreshed compilers
In keeping with the new versioning scheme for this project, the version has been revved to 3.11 to match the version of the compilers included.

Просмотреть файл

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),RoslynCodeProvider.sln))\tools\RoslynCodeProvider.settings.targets" />
<PropertyGroup>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<NuGetPackageId>$(MSBuildProjectName)</NuGetPackageId>
<NuSpecFile>$(MSBuildProjectName).nuspec</NuSpecFile>
<NuGetPackSymbols>false</NuGetPackSymbols>
<IsPackage>true</IsPackage>
</PropertyGroup>
<ItemGroup>
<NuGetContentProject Include="$(RepositoryRoot)\src\Microsoft.CodeDom.Providers.DotNetCompilerPlatform\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.csproj" />
<NuGetContent Include="Content\web.config.install.xdt">
<Destination>content\net472\web.config.install.xdt</Destination>
</NuGetContent>
<NuGetContent Include="Content\web.config.uninstall.xdt">
<Destination>content\net472\web.config.uninstall.xdt</Destination>
</NuGetContent>
<NuGetContent Include="tools\*.ps1" Condition="'$(SignAssembly)' != 'true'">
<Destination>tools</Destination>
</NuGetContent>
<NuGetContent Include="tools\signed\*.ps1" Condition="'$(SignAssembly)' == 'true'">
<Destination>tools</Destination>
</NuGetContent>
<NuGetContent Include="Readme.md">
<Destination>docs\Readme.md</Destination>
</NuGetContent>
<NuGetContent Include="..\icons\*">
<Destination>icons</Destination>
</NuGetContent>
</ItemGroup>
<Import Project="$(RepositoryRoot)Tools\NuGetProj.targets"/>
<Target Name="SignPowerShellScript" Condition=" '$(SignAssembly)' == 'true' " AfterTargets="BeforeBuild">
<ItemGroup>
<OriginalScriptFiles Include="$(MSBuildThisFileDirectory)\tools\*.ps1" />
</ItemGroup>
<Copy SourceFiles="@(OriginalScriptFiles)" DestinationFolder="$(MSBuildThisFileDirectory)\tools\signed" SkipUnchangedFiles="true" />
<ItemGroup>
<ScriptFilesToSign Include="$(MSBuildThisFileDirectory)\tools\signed\*.ps1">
<Authenticode>Microsoft400</Authenticode>
</ScriptFilesToSign>
</ItemGroup>
<SignFiles Files="@(ScriptFilesToSign)" Type="$(SignType)" BinariesDirectory="$(MSBuildThisFileDirectory)\tools\signed"
IntermediatesDirectory="$(MSBuildThisFileDirectory)\tools" ESRPSigning="$(ESRPSigning)" UseBearerToken="$(UseBearerToken)" />
</Target>
<Target Name="AfterBuild">
<PropertyGroup>
<OutDir>$(PackageOutputDir)</OutDir>
</PropertyGroup>
<ItemGroup>
<FilesToSign Include="$(NuGetPackTargetFile)" Condition="'$(SignAssembly)' == 'true'">
<Authenticode>NuGet</Authenticode>
</FilesToSign>
</ItemGroup>
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>$NuGetPackageId$</id>
<title>WebSite Installer for CodeDOM Providers for .NET Compiler Platform ("Roslyn")</title>
<version>$NuGetPackageVersion$</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
<description>An installer shim to get "Roslyn" CodeDOM providers included in project-less "Web Site" builds.
This package was built from the source at $GitCommitLink$
</description>
<summary>WebSite Shim for CodeDOM providers that use the new .NET Compiler Platform ("Roslyn") compiler as a service APIs.</summary>
<language>en-US</language>
<projectUrl>https://github.com/aspnet/RoslynCodeDomProvider</projectUrl>
<repository type="git" url="https://github.com/aspnet/RoslynCodeDomProvider" commit="$GitCommit$"/>
<icon>icons\dotnet.png</icon>
<readme>docs\Readme.md</readme>
<license type="expression">MIT</license>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<tags>Roslyn CodeDOM Compiler CSharp VB.Net ASP.NET WebSite</tags>
<dependencies>
<dependency id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="[$NuGetPackageVersion$]" />
</dependencies>
</metadata>
</package>

Просмотреть файл

@ -0,0 +1,6 @@
## Web Site integration for 4.X DotNetCompilerPlatform CodeDom Provider
This is a support package to enable proper integration of the 4.X series of the [Microsoft.CodeDom.Providers.DotNetCompilerPlatform](https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform) package with project-less "Web Sites." This package does not contain any libraries or providers of it's own. It simply restores the old 'install.ps1' nuget functionality to its tightly coupled 'DotNetCompilerPlatform' package dependency. Powershell installation was the only way to integrate with "Web Sites" which have very limited msbuild support.
This package has an exact dependency on the _DotNetCompilerPlatform_ package of the same version.
This package will fail to install on non-"Web Site" projects.

Просмотреть файл

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- If system.codedom tag is absent -->
<system.codedom xdt:Transform="InsertIfMissing">
</system.codedom>
<!-- If compilers tag is absent -->
<system.codedom>
<compilers xdt:Transform="InsertIfMissing" />
</system.codedom>
<!-- If a .cs compiler is already present, the existing entry needs to be removed before inserting the new entry -->
<system.codedom>
<compilers>
<compiler
extension=".cs"
xdt:Transform="Remove"
xdt:Locator="Match(extension)" />
</compilers>
</system.codedom>
<!-- If a .vb compiler is already present, the existing entry needs to be removed before inserting the new entry -->
<system.codedom>
<compilers>
<compiler
extension=".vb"
xdt:Transform="Remove"
xdt:Locator="Match(extension)" />
</compilers>
</system.codedom>
</configuration>

Просмотреть файл

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="aspnet:RoslynCompilerLocation" value="roslyn" xdt:Transform="Remove" xdt:Locator="Condition(@key='aspnet:RoslynCompilerLocation' and @value='roslyn')" />
</appSettings>
<appSettings xdt:Transform="Remove" xdt:Locator="Condition(count(child::*) = 0)">
</appSettings>
<system.codedom>
<compilers xdt:Transform="Remove" xdt:Locator="Condition(count(child::*) = 0)" />
</system.codedom>
<system.codedom xdt:Transform="Remove" xdt:Locator="Condition(count(child::*) = 0)" />
</configuration>

Просмотреть файл

@ -0,0 +1,254 @@
# Copyright (c) .NET Foundation. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
##
## Assigning a "DefaultValue" to a ParameterDescription will result in emitting this parameter when
## writing out a default compiler declaration.
##
## Setting IsRequired to $true will require the attribute to be set on all declarations in config.
##
if ((-not ("CompilerParameterDescription" -as [type])) -or (-not ("CodeDomProviderDescription" -as [type])))
{
Add-Type @"
using System;
public class CompilerParameterDescription {
public string Name;
public string DefaultValue;
public bool IsRequired;
public bool IsProviderOption;
}
public class CodeDomProviderDescription {
public string TypeName;
public string Assembly;
public string Version;
public string FileExtension;
public CompilerParameterDescription[] Parameters;
}
"@
}
function InstallCodeDomProvider($providerDescription) {
##### Update/Rehydrate config declarations #####
$config = ReadConfigFile
$rehydratedCount = RehydrateOldDeclarations $config $providerDescription
$updatedCount = UpdateDeclarations $config $providerDescription
##### Add the default provider if it wasn't rehydrated above
$defaultProvider = $config.xml.configuration["system.codedom"].compilers.compiler | where { $_.extension -eq $providerDescription.FileExtension }
if ($defaultProvider -eq $null) { AddDefaultDeclaration $config $providerDescription }
SaveConfigFile $config | Out-Null
}
function UninstallCodeDomProvider($providerType) {
##### Dehydrate config declarations #####
$config = ReadConfigFile
DehydrateDeclarations $config $providerType | Out-Null
SaveConfigFile $config | Out-Null
}
function GetConfigFileName() {
# Try web.config first. Then fall back to app.config.
$configFile = $project.ProjectItems | where { $_.Name -ieq "web.config" }
if ($configFile -eq $null) { $configFile = $project.ProjectItems | where { $_.Name -ieq "app.config" } }
$configPath = $configFile.Properties | where { $_.Name -ieq "LocalPath" }
if ($configPath -eq $null) { $configPath = $configFile.Properties | where { $_.Name -ieq "FullPath" } }
return $configPath.Value
}
function GetTempFileName() {
$uname = $project.UniqueName
if ([io.path]::IsPathRooted($uname)) { $uname = $project.Name }
return [io.path]::Combine($env:TEMP, "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Temp", $uname + ".xml")
}
function ReadConfigFile() {
$configFile = GetConfigFileName
$configObj = @{ fileName = $configFile; xml = (Select-Xml -Path "$configFile" -XPath /).Node }
$configObj.xml.PreserveWhitespace = $true
return $configObj
}
function DehydrateDeclarations($config, $typeName) {
$tempFile = GetTempFileName
$count = 0
if ([io.file]::Exists($tempFile)) {
$xml = (Select-Xml -Path "$tempFile" -XPath /).Node
$xml.PreserveWhitespace = $true
} else {
$xml = New-Object System.Xml.XmlDocument
$xml.PreserveWhitespace = $true
$xml.AppendChild($xml.CreateElement("driedDeclarations")) | Out-Null
}
foreach ($rec in $config.xml.configuration["system.codedom"].compilers.compiler | where { IsSameType $_.type $typeName }) {
# Remove records from config.
$config.xml.configuration["system.codedom"].compilers.RemoveChild($rec) | Out-Null
# Add the record to the temp stash. Don't worry about duplicates.
AppendChildNode $xml.ImportNode($rec, $true) $xml.DocumentElement | Out-Null
$count++
}
# Save the dehydrated declarations
$tmpFolder = Split-Path $tempFile
md -Force $tmpFolder | Out-Null
$xml.Save($tempFile) | Out-Null
return $count
}
function RehydrateOldDeclarations($config, $providerDescription) {
$tempFile = GetTempFileName
if (![io.file]::Exists($tempFile)) { return 0 }
$count = 0
$xml = (Select-Xml -Path "$tempFile" -XPath /).Node
$xml.PreserveWhitespace = $true
foreach($rec in $xml.driedDeclarations.compiler | where { IsSameType $_.type ($providerDescription.TypeName + "," + $providerDescription.Assembly) }) {
# Remove records that match type, even if we don't end up rehydrating them.
$xml.driedDeclarations.RemoveChild($rec) | Out-Null
# Skip if an existing record of the same file extension already exists.
$existingRecord = $config.xml.configuration["system.codedom"].compilers.compiler | where { $_.extension -eq $rec.extension }
if ($existingRecord -ne $null) { continue }
# Bring the record back to life
AppendChildNode $config.xml.ImportNode($rec, $true) $config.xml.configuration["system.codedom"]["compilers"] | Out-Null
$count++
Write-Host "Restored system.codedom compiler for extension '$($rec.extension)'."
}
# Make dried record removal permanent
$xml.Save($tempFile) | Out-Null
return $count
}
function UpdateDeclarations($config, $providerDescription) {
$count = 0
foreach ($provider in $config.xml.configuration["system.codedom"].compilers.compiler | where { IsSameType $_.type ($providerDescription.TypeName + "," + $providerDescription.Assembly) }) {
$failed = $false
# Add default attributes if they are required and not already present
foreach ($p in $providerDescription.Parameters | where { ($_.IsRequired -eq $true) -and ($_.IsProviderOption -eq $false) }) {
if ($provider.($p.Name) -eq $null) {
if ($p.DefaultValue -eq $null) {
Write-Warning "Failed to add parameter to '$($provider.name)' codeDom provider: '$($p.Name)' is required, but does not have a default value."
$failed = $true
}
$attr = $config.xml.CreateAttribute($p.Name)
$attr.Value = $p.DefaultValue
$provider.Attributes.InsertBefore($attr, $provider.Attributes["type"]) | Out-Null
}
}
# Do the same thing for default providerOptions if not already present
foreach ($p in $providerDescription.Parameters | where { ($_.IsRequired -eq $true) -and ($_.IsProviderOption -eq $true)}) {
$existing = $provider.providerOption | where { $_.name -eq $p.Name }
if ($existing -eq $null) {
if ($p.DefaultValue -eq $null) {
Write-Warning "Failed to add providerOption to '$($provider.name)' codeDom provider: '$($p.Name)' is required, but does not have a default value."
$failed = $true
}
$po = $config.xml.CreateElement("providerOption")
$po.SetAttribute("name", $p.Name) | Out-Null
$po.SetAttribute("value", $p.DefaultValue) | Out-Null
AppendChildNode $po $provider 4 | Out-Null
}
}
# Finally, update type. And do so with remove/add so the 'type' parameter gets put at the end
$provider.RemoveAttribute("type") | Out-Null
$provider.SetAttribute("type", "$($providerDescription.TypeName), $($providerDescription.Assembly), Version=$($providerDescription.Version), Culture=neutral, PublicKeyToken=31bf3856ad364e35") | Out-Null
if ($failed -ne $true) { $count++ }
}
return $count
}
function AddDefaultDeclaration($config, $providerDescription) {
$dd = $config.xml.CreateElement("compiler")
# file extension first
$dd.SetAttribute("extension", $providerDescription.FileExtension) | Out-Null
# everything else in the middle
foreach ($p in $providerDescription.Parameters) {
if ($p.IsRequired -and ($p.DefaultValue -eq $null)) {
Write-Host "Failed to add default declaration for code dom extension '$($providerDescription.FileExtension)': '$($p.Name)' is required, but does not have a default value."
return
}
if ($p.DefaultValue -ne $null) {
if ($p.IsProviderOption -eq $true) {
$po = $config.xml.CreateElement("providerOption")
$po.SetAttribute("name", $p.Name) | Out-Null
$po.SetAttribute("value", $p.DefaultValue) | Out-Null
AppendChildNode $po $dd 4 | Out-Null
} else {
$dd.SetAttribute($p.Name, $p.DefaultValue) | Out-Null
}
}
}
# type last
$dd.SetAttribute("type", "$($providerDescription.TypeName), $($providerDescription.Assembly), Version=$($providerDescription.Version), Culture=neutral, PublicKeyToken=31bf3856ad364e35") | Out-Null
AppendChildNode $dd $config.xml.configuration["system.codedom"]["compilers"] | Out-Null
Write-Host "Added system.codedom compiler for extension '$($dd.extension)'."
}
function AppendChildNode($provider, $parent, $indentLevel = 3) {
$lastSibling = $parent.ChildNodes | where { $_ -isnot [System.Xml.XmlWhitespace] } | select -Last 1
if ($lastSibling -ne $null) {
# If not the first child, then copy the whitespace convention of the existing child
$ws = "";
$prev = $lastSibling.PreviousSibling | where { $_ -is [System.Xml.XmlWhitespace] }
while ($prev -ne $null) {
$ws = $prev.data + $ws
$prev = $prev.PreviousSibling | where { $_ -is [System.Xml.XmlWhitespace] }
}
$parent.InsertAfter($provider, $lastSibling) | Out-Null
if ($ws.length -gt 0) { $parent.InsertAfter($parent.OwnerDocument.CreateWhitespace($ws), $lastSibling) | Out-Null }
return
}
# Add on a new line with indents. Make sure there is no existing whitespace mucking this up.
foreach ($exws in $parent.ChildNodes | where { $_ -is [System.Xml.XmlWhitespace] }) { $parent.RemoveChild($exws) | Out-Null }
$parent.AppendChild($parent.OwnerDocument.CreateWhitespace("`r`n")) | Out-Null
$parent.AppendChild($parent.OwnerDocument.CreateWhitespace(" " * $indentLevel)) | Out-Null
$parent.AppendChild($provider) | Out-Null
$parent.AppendChild($parent.OwnerDocument.CreateWhitespace("`r`n")) | Out-Null
$parent.AppendChild($parent.OwnerDocument.CreateWhitespace(" " * ($indentLevel - 1))) | Out-Null
}
function SaveConfigFile($config) {
$config.xml.Save($config.fileName) | Out-Null
}
function IsSameType($typeString1, $typeString2) {
if (($typeString1 -eq $null) -or ($typeString2 -eq $null)) { return $false }
# First check the type
$t1 = $typeString1.Split(',')[0].Trim()
$t2 = $typeString2.Split(',')[0].Trim()
if ($t1 -cne $t2) { return $false }
# Then check for assembly match if possible
$a1 = $typeString1.Split(',')[1]
$a2 = $typeString2.Split(',')[1]
if (($a1 -ne $null) -and ($a2 -ne $null)) {
return ($a1.Trim() -eq $a2.Trim())
}
# Don't care about assembly. Match is good.
return $true
}

Просмотреть файл

@ -0,0 +1,96 @@
# Copyright (c) .NET Foundation. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
######################################################################################################
## The main MS.CD.Providers.DotNetCompilerPlatform package uses targets files to do all this work ##
## at build time. WebSite 'projects' can't take advantage of msbuild/targets files, so this package ##
## brings back the install.ps1 functionality that shoehorns bits into WebSite builds. ##
######################################################################################################
param($installPath, $toolsPath, $package, $project)
$assemblyVersion = '4.1.0.0'
if ($project -eq $null) {
$project = Get-Project
}
# This package is only for WebSite "projects."
# Fail noisily if trying to install on any other project type.
if ($project.Type -ne 'Web Site')
{
throw "This package is intended only for 'Web Site' projects. Aborting install."
}
$compilerVersion = $package.Version
if($package.Versions -ne $null) { $compilerVersion = @($package.Versions)[0] }
$projectRoot = $project.Properties.Item('FullPath').Value
$binDirectory = Join-Path $projectRoot 'bin'
$roslynSubFolder = 'roslyn'
$packageDirectory = Split-Path $installPath
$compilerPackageName = "Microsoft.CodeDom.Providers.DotNetCompilerPlatform." + $compilerVersion
$compilerPackageDirectory = Join-Path $packageDirectory $compilerPackageName
$providerBits = Join-Path $compilerPackageDirectory "lib\net472"
$roslynBits = Join-Path $compilerPackageDirectory "tools\Roslyn-$compilerVersion"
$csLanguageVersion = '7.3'
$vbLanguageVersion = 'default'
# Check for existence of the roslyn codedom provider package before continuing
if ((Get-Item $compilerPackageDirectory) -isnot [System.IO.DirectoryInfo])
{
throw "The install.ps1 cannot find the installation location of package $compilerPackageName, or the pakcage is not installed correctly."
}
# Fill out the config entries for these code dom providers here. Using powershell to do
# this allows us to cache and restore customized attribute values from previous versions of
# this package in the upgrade scenario.
. "$PSScriptRoot\common.ps1"
$csCodeDomProvider = [CodeDomProviderDescription]@{
TypeName="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider";
Assembly="Microsoft.CodeDom.Providers.DotNetCompilerPlatform";
Version=$assemblyVersion;
FileExtension=".cs";
Parameters=@(
[CompilerParameterDescription]@{ Name="language"; DefaultValue="c#;cs;csharp"; IsRequired=$true; IsProviderOption=$false },
[CompilerParameterDescription]@{ Name="warningLevel"; DefaultValue="4"; IsRequired=$true; IsProviderOption=$false },
[CompilerParameterDescription]@{ Name="compilerOptions"; DefaultValue="/langversion:" + $csLanguageVersion + " /nowarn:1659;1699;1701;612;618"; IsRequired=$false; IsProviderOption=$false });
}
InstallCodeDomProvider $csCodeDomProvider
$vbCodeDomProvider = [CodeDomProviderDescription]@{
TypeName="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider";
Assembly="Microsoft.CodeDom.Providers.DotNetCompilerPlatform";
Version=$assemblyVersion;
FileExtension=".vb";
Parameters=@(
[CompilerParameterDescription]@{ Name="language"; DefaultValue="vb;vbs;visualbasic;vbscript"; IsRequired=$true; IsProviderOption=$false },
[CompilerParameterDescription]@{ Name="warningLevel"; DefaultValue="4"; IsRequired=$true; IsProviderOption=$false },
[CompilerParameterDescription]@{ Name="compilerOptions"; DefaultValue="/langversion:" + $vbLanguageVersion + " /nowarn:41008,40000,40008 /define:_MYTYPE=\""Web\"" /optionInfer+"; IsRequired=$false; IsProviderOption=$false });
}
InstallCodeDomProvider $vbCodeDomProvider
# We need to copy the provider assembly into the bin\ folder, otherwise
# Microsoft.VisualStudio.Web.Host.exe cannot find the assembly.
# However, users will see the error after they clean solutions.
New-Item $binDirectory -type directory -force | Out-Null
Copy-Item $providerBits\* $binDirectory -force | Out-Null
# Copy the Roslyn toolset into the website's bin folder as well.
$roslynSubDirectory = Join-Path $binDirectory $roslynSubFolder
New-Item $roslynSubDirectory -type directory -force | Out-Null
Copy-Item $roslynBits\* $roslynSubDirectory -force | Out-Null
# Generate a .refresh file for each dll/exe file.
Push-Location
Set-Location $projectRoot
$relativeAssemblySource = Resolve-Path -relative $roslynBits
Pop-Location
Get-ChildItem -Path $roslynSubDirectory | `
Foreach-Object {
if (($_.Extension -eq ".dll") -or ($_.Extension -eq ".exe")) {
$refreshFile = $_.FullName
$refreshFile += ".refresh"
$refreshContent = Join-Path $relativeAssemblySource $_.Name
Set-Content $refreshFile $refreshContent
}
}

Просмотреть файл

@ -0,0 +1,37 @@
# Copyright (c) .NET Foundation. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
######################################################################################################
## The main MS.CD.Providers.DotNetCompilerPlatform package uses targets files to do all this work ##
## at build time. WebSite 'projects' can't take advantage of msbuild/targets files, so this package ##
## brings back the install.ps1 functionality that shoehorns bits into WebSite builds. ##
######################################################################################################
param($installPath, $toolsPath, $package, $project)
# This package is only for WebSite "projects"
if ($project.Type -eq 'Web Site') {
# First save the code dom compiler declarations off to a temp file so they can be restored
# in the event that this is a package upgrade scenario.
. "$PSScriptRoot\common.ps1"
UninstallCodeDomProvider "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform"
UninstallCodeDomProvider "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform"
# Then remove the compiler bits from the bin directory
$roslynSubFolder = 'roslyn'
if ($project -eq $null) {
$project = Get-Project
}
$projectRoot = $project.Properties.Item('FullPath').Value
$binDirectory = Join-Path $projectRoot 'bin'
$targetDirectory = Join-Path $binDirectory $roslynSubFolder
if (Test-Path $targetDirectory) {
Get-Process -Name "VBCSCompiler" -ErrorAction SilentlyContinue | Stop-Process -Force -PassThru -ErrorAction SilentlyContinue | Wait-Process
Remove-Item $targetDirectory -Force -Recurse -ErrorAction SilentlyContinue
}
}

Просмотреть файл

@ -35,6 +35,9 @@
<NuGetContent Include="tools\$(LocalRoslynFolderName)\*">
<Destination>tools\$(LocalRoslynFolderName)</Destination>
</NuGetContent>
<NuGetContent Include="Readme.md">
<Destination>docs\Readme.md</Destination>
</NuGetContent>
<NuGetContent Include="..\icons\*">
<Destination>icons</Destination>
</NuGetContent>

Просмотреть файл

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>$NuGetPackageId$</id>
<title>CodeDOM Providers for .NET Compiler Platform ("Roslyn")</title>
@ -14,7 +14,9 @@
<summary>Replacement CodeDOM providers that use the new .NET Compiler Platform ("Roslyn") compiler as a service APIs.</summary>
<language>en-US</language>
<projectUrl>https://github.com/aspnet/RoslynCodeDomProvider</projectUrl>
<repository type="git" url="https://github.com/aspnet/RoslynCodeDomProvider" commit="$GitCommit$" />
<icon>icons\dotnet.png</icon>
<readme>docs\Readme.md</readme>
<license type="expression">MIT</license>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<tags>Roslyn CodeDOM Compiler CSharp VB.Net ASP.NET</tags>

Просмотреть файл

@ -0,0 +1,23 @@
## :warning: Project-less 'WebSite's should use [....DotNetCompilerPlatform.WebSites](https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites) package :warning:
Version 4.X of this package has moved fully into an msbuild/targets model. But "Web Site"s - because they are "project-less" - have very limited support in msbuild and the package does not fully install like it did in the 3.X and earlier releases. Please use the [Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites](https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites) package for proper integration with a "Web Site" project.
## Introduction
Replacement CodeDOM providers that use the new .NET Compiler Platform ("Roslyn") compiler as a service APIs. This provides support for new language features in systems using CodeDOM (e.g. ASP.NET runtime compilation) as well as improving the compilation performance of these systems.
Please see the blog [Enabling the .NET Compiler Platform (“Roslyn”) in ASP.NET applications](https://blogs.msdn.microsoft.com/webdev/2014/05/12/enabling-the-net-compiler-platform-roslyn-in-asp-net-applications/)
for an introduction to Microsoft.CodeDom.Providers.DotNetCompilerPlatform. The [project github](https://github.com/aspnet/RoslynCodeDomProvider) also has the most up-to-date documentation of the various settings available for configuring this provider.
## Updates
+ #### Version 4.1.0 (preview1)
- #### Drop install.ps1, Rely more on msbuild
Nuget has moved on from install.ps1. We had one foot in the msbuild camp before, and one foot still in the install.ps1 camp. Time to just jump in with both feet. See the 'RoslynRegisterInConfig' setting description below.
- #### Refreshed current compilers
In keeping with the new versioning scheme for this project, the version has been revved to 4.1 to match the version of the compilers included.
- #### No more old compilers
Stop carrying old versions of compilers. If you upgrade to get new compilers, you get new compilers. The old compilers that might carry references to binaries that get flagged in security scans even though the binaries don't get copied to the ouput directory... they just won't be included in the package anymore.
- #### .Net >= 4.7.2
As a result of not keeping older compilers packaged in this project, we can no longer support versions before 4.7.2 because compiler versions 3.0 and newer only support 4.7.2+.

Просмотреть файл

@ -22,15 +22,23 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<ItemGroup Label="Nuget Project Build Order">
<NuGetProject Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuproj" />
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuspec" />
<NuGetProject Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites.nuproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Label="Main Provider">
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuspec" />
<None Include="MIcrosoft.CodeDom.Providers.DotNetCompilerPlatform\Readme.md" />
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets" />
</ItemGroup>
<ItemGroup>
<Folder Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform\tools\" />
<ItemGroup Label="WebSite Shim">
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites.nuspec" />
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites\Readme.md" />
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites\content\web.config.install.xdt" />
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites\content\web.config.uninstall.xdt" />
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites\tools\common.ps1" />
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites\tools\install.ps1" />
<None Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites\tools\uninstall.ps1" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="Build">

Просмотреть файл

@ -184,7 +184,11 @@ Common build targets overwrites.
<RebuildDependsOn>Clean;Build</RebuildDependsOn>
</PropertyGroup>
<Target Name="BeforeBuild" />
<Target Name="BeforeBuild">
<ItemGroup>
<NuGetContent Remove="@(NuGetContent)"/>
</ItemGroup>
</Target>
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />
<Target Name="AfterBuild" />

Просмотреть файл

@ -3,6 +3,7 @@
<!-- Build order -->
<PropertyGroup>
<BuildDependsOn>SetNuSpecProperties;DownloadRoslynBinariesToToolsFolder;$(BuildDependsOn)</BuildDependsOn>
<GitCommit Condition=" '$(GitCommit)' == '' "></GitCommit>
<GitCommitLink Condition=" '$(GitCommitLink)' == '' "></GitCommitLink>
</PropertyGroup>
@ -25,6 +26,7 @@
<NuSpecProperties>
NuGetPackageVersion=$(NuGetPackageVersion);
NuGetPackageId=$(NuGetPackageId);
GitCommit=$(GitCommit);
GitCommitLink=$(GitCommitLink);
</NuSpecProperties>
</PropertyGroup>