Skip to content

Instantly share code, notes, and snippets.

@MartinMiles
Created April 20, 2021 22:45
Show Gist options
  • Save MartinMiles/6873bf1cc44528c6c1c1b6d148ffae8a to your computer and use it in GitHub Desktop.
Save MartinMiles/6873bf1cc44528c6c1c1b6d148ffae8a to your computer and use it in GitHub Desktop.
Updates Microsoft.Net.Compilers and Microsoft.CodeDom.Providers.DotNetCompilerPlatform for th latest version across the whole solution within *.csproj and packages.config files
gci -r -include "*.csproj" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform.\d+.\d+.\d+\\build\\net\d{1,3}\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props','Microsoft.CodeDom.Providers.DotNetCompilerPlatform.3.6.0\build\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "*.csproj" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace 'Microsoft.Net.Compilers.\d+.\d+.\d+','Microsoft.Net.Compilers.3.9.0' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "packages.config" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace '<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="\d+.\d+.\d+" targetFramework="net\d{1,3}" ','<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="3.6.0" targetFramework="net48" ' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "packages.config" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace '<package id="Microsoft.Net.Compilers" version="\d+.\d+.\d+" targetFramework="net\d+" developmentDependency="true" />','<package id="Microsoft.Net.Compilers" version="3.9.0" targetFramework="net48" developmentDependency="true" />' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "*.csproj" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=\d.\d.\d.0,','Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0,' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "*.csproj" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform.\d+.\d+.\d+\\lib','Microsoft.CodeDom.Providers.DotNetCompilerPlatform.3.6.0\lib' } | set-content -NoNewLine $a -Encoding UTF8}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment