diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config index efc5e59..e47923b 100644 --- a/.nuget/NuGet.Config +++ b/.nuget/NuGet.Config @@ -5,10 +5,6 @@ - + - - - - \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe index 4cbab24..212f26c 100644 Binary files a/.nuget/NuGet.exe and b/.nuget/NuGet.exe differ diff --git a/README.md b/README.md index 50cd336..ad3ac2f 100644 --- a/README.md +++ b/README.md @@ -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. + + **Moving fully to an msbuild/targets-based model will break project-less ASP.Net "Web Sites."** 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. diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites.nuproj b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites.nuproj new file mode 100644 index 0000000..92de591 --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites.nuproj @@ -0,0 +1,56 @@ + + + + + $(MSBuildProjectName) + $(MSBuildProjectName) + $(MSBuildProjectName).nuspec + false + true + + + + + content\net472\web.config.install.xdt + + + content\net472\web.config.uninstall.xdt + + + tools + + + tools + + + docs\Readme.md + + + icons + + + + + + + + + + + Microsoft400 + + + + + + + $(PackageOutputDir) + + + + NuGet + + + + \ No newline at end of file diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites.nuspec b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites.nuspec new file mode 100644 index 0000000..dc9730c --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites.nuspec @@ -0,0 +1,29 @@ + + + + $NuGetPackageId$ + WebSite Installer for CodeDOM Providers for .NET Compiler Platform ("Roslyn") + $NuGetPackageVersion$ + Microsoft + Microsoft + © Microsoft Corporation. All rights reserved. + An installer shim to get "Roslyn" CodeDOM providers included in project-less "Web Site" builds. + + This package was built from the source at $GitCommitLink$ + + WebSite Shim for CodeDOM providers that use the new .NET Compiler Platform ("Roslyn") compiler as a service APIs. + en-US + https://github.com/aspnet/RoslynCodeDomProvider + + icons\dotnet.png + docs\Readme.md + MIT + true + Roslyn CodeDOM Compiler CSharp VB.Net ASP.NET WebSite + + + + + + + \ No newline at end of file diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Readme.md b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Readme.md new file mode 100644 index 0000000..5c2d56f --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/Readme.md @@ -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. diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/content/web.config.install.xdt b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/content/web.config.install.xdt new file mode 100644 index 0000000..8bdd7c4 --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/content/web.config.install.xdt @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/content/web.config.uninstall.xdt b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/content/web.config.uninstall.xdt new file mode 100644 index 0000000..8dee510 --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/content/web.config.uninstall.xdt @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/common.ps1 b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/common.ps1 new file mode 100644 index 0000000..0d74e30 --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/common.ps1 @@ -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 +} diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/install.ps1 b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/install.ps1 new file mode 100644 index 0000000..27c8c9e --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/install.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/uninstall.ps1 b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/uninstall.ps1 new file mode 100644 index 0000000..55a8745 --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.WebSites/tools/uninstall.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuproj b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuproj index a2881e0..6a61034 100644 --- a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuproj +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuproj @@ -35,6 +35,9 @@ tools\$(LocalRoslynFolderName) + + docs\Readme.md + icons diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuspec b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuspec index b9f91dd..e1d2aa7 100644 --- a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuspec +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.nuspec @@ -1,5 +1,5 @@  - + $NuGetPackageId$ CodeDOM Providers for .NET Compiler Platform ("Roslyn") @@ -14,7 +14,9 @@ Replacement CodeDOM providers that use the new .NET Compiler Platform ("Roslyn") compiler as a service APIs. en-US https://github.com/aspnet/RoslynCodeDomProvider + icons\dotnet.png + docs\Readme.md MIT true Roslyn CodeDOM Compiler CSharp VB.Net ASP.NET diff --git a/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Readme.md b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Readme.md new file mode 100644 index 0000000..05cb1ef --- /dev/null +++ b/src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Readme.md @@ -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+. + diff --git a/src/Packages/Packages.csproj b/src/Packages/Packages.csproj index fbe52a6..4a299cc 100644 --- a/src/Packages/Packages.csproj +++ b/src/Packages/Packages.csproj @@ -22,15 +22,23 @@ false - + - + - + + + - - + + + + + + + + diff --git a/tools/NuGetProj.targets b/tools/NuGetProj.targets index f9dff87..1d8208c 100644 --- a/tools/NuGetProj.targets +++ b/tools/NuGetProj.targets @@ -184,7 +184,11 @@ Common build targets overwrites. Clean;Build - + + + + + diff --git a/tools/RoslynCodeProvider.targets b/tools/RoslynCodeProvider.targets index 7cac6b9..5be79f6 100644 --- a/tools/RoslynCodeProvider.targets +++ b/tools/RoslynCodeProvider.targets @@ -3,6 +3,7 @@ SetNuSpecProperties;DownloadRoslynBinariesToToolsFolder;$(BuildDependsOn) + @@ -25,6 +26,7 @@ NuGetPackageVersion=$(NuGetPackageVersion); NuGetPackageId=$(NuGetPackageId); + GitCommit=$(GitCommit); GitCommitLink=$(GitCommitLink);