Skip to content

Commit 2389fc7

Browse files
authored
Use newer Roslyn compiler for Razor views, fix debug attribute in CDNRedirect (#10650)
* Use Microsoft.CodeDom.Providers.DotNetCompilerPlatform in Gallery * Use latest language version like .csproj * Check in debug for CDNRedirect web.config, remove it for release builds, like gallery
1 parent 5813088 commit 2389fc7

7 files changed

Lines changed: 115 additions & 35 deletions

File tree

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<PackageVersion Include="Microsoft.Azure.Storage.DataMovement" Version="0.9.0" />
6161
<PackageVersion Include="Microsoft.Bcl.Compression" Version="3.9.85" />
6262
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
63-
<PackageVersion Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="3.6.0" />
63+
<PackageVersion Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="4.1.0" />
6464
<PackageVersion Include="Microsoft.Data.Services.Client" Version="5.8.4" />
6565
<PackageVersion Include="Microsoft.Data.Services" Version="5.8.4" />
6666
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />

src/NuGetCDNRedirect/NuGetCDNRedirect.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@
110110
<ItemGroup>
111111
<WCFMetadata Include="Connected Services\" />
112112
</ItemGroup>
113+
<ItemGroup>
114+
<None Include="Web.Debug.config">
115+
<DependentUpon>Web.config</DependentUpon>
116+
</None>
117+
<None Include="Web.Release.config">
118+
<DependentUpon>Web.config</DependentUpon>
119+
</None>
120+
</ItemGroup>
113121
<PropertyGroup>
114122
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
115123
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0"?>
2+
3+
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
4+
5+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
6+
<!--
7+
In the example below, the "SetAttributes" transform will change the value of
8+
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
9+
finds an attribute "name" that has a value of "MyDB".
10+
11+
<connectionStrings>
12+
<add name="MyDB"
13+
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
14+
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
15+
</connectionStrings>
16+
-->
17+
<system.web>
18+
<!--
19+
In the example below, the "Replace" transform will replace the entire
20+
<customErrors> section of your web.config file.
21+
Note that because there is only one customErrors section under the
22+
<system.web> node, there is no need to use the "xdt:Locator" attribute.
23+
24+
<customErrors defaultRedirect="GenericError.htm"
25+
mode="RemoteOnly" xdt:Transform="Replace">
26+
<error statusCode="500" redirect="InternalError.htm"/>
27+
</customErrors>
28+
-->
29+
</system.web>
30+
</configuration>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0"?>
2+
3+
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
4+
5+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
6+
<!--
7+
In the example below, the "SetAttributes" transform will change the value of
8+
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
9+
finds an attribute "name" that has a value of "MyDB".
10+
11+
<connectionStrings>
12+
<add name="MyDB"
13+
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
14+
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
15+
</connectionStrings>
16+
-->
17+
<system.web>
18+
<compilation xdt:Transform="RemoveAttributes(debug)" />
19+
20+
<!-- This is set to 'false' for security reasons. -->
21+
<trace xdt:Transform="Remove"/>
22+
<trace xdt:Transform="InsertAfter(/configuration/system.web/compilation)" enabled="false"/>
23+
24+
<!--
25+
In the example below, the "Replace" transform will replace the entire
26+
<customErrors> section of your web.config file.
27+
Note that because there is only one customErrors section under the
28+
<system.web> node, there is no need to use the "xdt:Locator" attribute.
29+
30+
<customErrors defaultRedirect="GenericError.htm"
31+
mode="RemoteOnly" xdt:Transform="Replace">
32+
<error statusCode="500" redirect="InternalError.htm"/>
33+
</customErrors>
34+
-->
35+
</system.web>
36+
</configuration>

src/NuGetCDNRedirect/Web.config

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
-->
66
<configuration>
77
<appSettings>
8-
<add key="webpages:Version" value="3.0.0.0"/>
9-
<add key="webpages:Enabled" value="false"/>
10-
<add key="ClientValidationEnabled" value="true"/>
11-
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
8+
<add key="webpages:Version" value="3.0.0.0" />
9+
<add key="webpages:Enabled" value="false" />
10+
<add key="ClientValidationEnabled" value="true" />
11+
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
1212
</appSettings>
1313
<!--
1414
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
@@ -19,79 +19,79 @@
1919
</system.Web>
2020
-->
2121
<system.web>
22-
<httpCookies requireSSL="true" httpOnlyCookies="true"/>
23-
<compilation debug="false" targetFramework="4.6.2"/>
24-
<httpRuntime targetFramework="4.6.1" enableVersionHeader="false"/>
22+
<httpCookies requireSSL="true" httpOnlyCookies="true" />
23+
<compilation debug="true" targetFramework="4.6.2" />
24+
<httpRuntime targetFramework="4.6.1" enableVersionHeader="false" />
2525
<httpModules>
26-
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
26+
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
2727
</httpModules>
2828
</system.web>
2929
<system.webServer>
30-
<validation validateIntegratedModeConfiguration="false"/>
30+
<validation validateIntegratedModeConfiguration="false" />
3131
<modules runAllManagedModulesForAllRequests="true">
32-
<remove name="TelemetryCorrelationHttpModule"/>
33-
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler"/>
34-
<remove name="ApplicationInsightsWebTracking"/>
35-
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
32+
<remove name="TelemetryCorrelationHttpModule" />
33+
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />
34+
<remove name="ApplicationInsightsWebTracking" />
35+
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
3636
</modules>
3737
<httpRedirect enabled="true" httpResponseStatus="Found">
38-
<add wildcard="*" destination="https://placeholder"/>
38+
<add wildcard="*" destination="https://placeholder" />
3939
</httpRedirect>
4040
<httpProtocol>
4141
<customHeaders>
42-
<remove name="X-Powered-By"/>
43-
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains"/>
42+
<remove name="X-Powered-By" />
43+
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains" />
4444
</customHeaders>
4545
</httpProtocol>
4646
<handlers>
47-
<remove name="StaticFile"/>
47+
<remove name="StaticFile" />
4848
</handlers>
4949
<security>
5050
<requestFiltering>
5151
<fileExtensions>
52-
<clear/>
52+
<clear />
5353
</fileExtensions>
5454
<hiddenSegments>
55-
<clear/>
55+
<clear />
5656
</hiddenSegments>
5757
</requestFiltering>
5858
</security>
5959
</system.webServer>
6060
<system.serviceModel>
61-
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
61+
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
6262
</system.serviceModel>
6363
<location path="Status/Index">
6464
<system.webServer>
65-
<httpRedirect enabled="false"/>
65+
<httpRedirect enabled="false" />
6666
</system.webServer>
6767
</location>
6868
<system.codedom>
6969
<compilers>
70-
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
71-
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
70+
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
71+
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
7272
</compilers>
7373
</system.codedom>
7474
<runtime>
7575
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
7676
<dependentAssembly>
77-
<assemblyIdentity name="WebGrease" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
78-
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
77+
<assemblyIdentity name="WebGrease" publicKeyToken="31BF3856AD364E35" culture="neutral" />
78+
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
7979
</dependentAssembly>
8080
<dependentAssembly>
81-
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
82-
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
81+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
82+
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
8383
</dependentAssembly>
8484
<dependentAssembly>
85-
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
86-
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
85+
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral" />
86+
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
8787
</dependentAssembly>
8888
<dependentAssembly>
89-
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
90-
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
89+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral" />
90+
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
9191
</dependentAssembly>
9292
<dependentAssembly>
93-
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
94-
<bindingRedirect oldVersion="0.0.0.0-5.2.9.0" newVersion="5.2.9.0"/>
93+
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31BF3856AD364E35" culture="neutral" />
94+
<bindingRedirect oldVersion="0.0.0.0-5.2.9.0" newVersion="5.2.9.0" />
9595
</dependentAssembly>
9696
</assemblyBinding>
9797
</runtime>

src/NuGetGallery/NuGetGallery.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,7 @@
22272227
</ItemGroup>
22282228
<ItemGroup>
22292229
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
2230+
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" />
22302231
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
22312232
<PackageReference Include="Microsoft.Extensions.Http" />
22322233
<PackageReference Include="Microsoft.Extensions.Http.Polly" />
@@ -2326,7 +2327,6 @@
23262327
<ItemGroup>
23272328
<Content Include="Views\Users\TrustedPublishing.cshtml" />
23282329
</ItemGroup>
2329-
23302330
<PropertyGroup>
23312331
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
23322332
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

src/NuGetGallery/Web.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@
322322
<EncryptedData/>
323323
</machineKey>
324324
</system.web>
325+
<system.codedom>
326+
<compilers>
327+
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" compilerOptions="/langversion:latest /nowarn:1659;1699;1701;612;618" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
328+
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
329+
</compilers>
330+
</system.codedom>
325331
<system.webServer>
326332
<tracing>
327333
<traceFailedRequests>

0 commit comments

Comments
 (0)