Skip to content

Commit

Permalink
Fix SuppressTrimAnalysisWarnings (#17050)
Browse files Browse the repository at this point in the history
* Fix SuppressTrimAnalysisWarnings

This needs to be set before the .NET SDK targets get imported, otherwise
the .NET defaults win.

* Test that blazorwasm doesn't produce trim warnings
  • Loading branch information
sbomer authored Apr 21, 2021
1 parent e75cf72 commit 23e7fd3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Copyright (c) .NET Foundation. All rights reserved.

<PropertyGroup>
<EnableDefaultContentItems Condition=" '$(EnableDefaultContentItems)' == '' ">true</EnableDefaultContentItems>

<!-- Trimmer defaults that depend on user-definable settings.
This must be configured before it's initialized in the .NET SDK targets (which are imported by the Razor SDK). -->
<SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == '' And '$(TrimmerDefaultAction)' != 'link'">true</SuppressTrimAnalysisWarnings>
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk.Razor" Project="Sdk.targets" />
Expand Down Expand Up @@ -61,9 +65,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<StaticWebAssetBasePath Condition="'$(StaticWebAssetBasePath)' == ''">/</StaticWebAssetBasePath>
<BlazorCacheBootResources Condition="'$(BlazorCacheBootResources)' == ''">true</BlazorCacheBootResources>

<!-- Trimmer defaults that depend on user-definable settings -->
<SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == '' And '$(TrimmerDefaultAction)' != 'link'">true</SuppressTrimAnalysisWarnings>

<!-- Turn off parts of the build that do not apply to WASM projects -->
<GenerateDependencyFile>false</GenerateDependencyFile>
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public void Publish_MinimalApp_Works()
var testInstance = CreateAspNetSdkTestAsset(testAppName);

var publishCommand = new PublishCommand(Log, testInstance.TestRoot);
publishCommand.Execute().Should().Pass();
publishCommand.Execute().Should().Pass()
.And.NotHaveStdOutContaining("warning IL");

var publishDirectory = publishCommand.GetOutputDirectory(DefaultTfm);

Expand Down
9 changes: 6 additions & 3 deletions src/WebSdk/Web/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- We can't add it here because the OutputPath and other msbuild properties are not evaluated.-->
<!--<Import Sdk="Microsoft.NET.Sdk.Publish" Project="ImportPublishProfile.targets" />-->

<PropertyGroup>
<!-- Trimmer defaults that depend on user-definable settings.
This must be configured before it's initialized in the .NET SDK targets. -->
<SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == '' And '$(TrimmerDefaultAction)' != 'link'">true</SuppressTrimAnalysisWarnings>
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />

<PropertyGroup>
Expand All @@ -22,9 +28,6 @@ Copyright (c) .NET Foundation. All rights reserved.
Microsoft.AspNetCore.App. This needs to happen after the .NET SDK has evaluated TFMs.
-->
<AddRazorSupportForMvc Condition="'$(DisableImplicitFrameworkReferences)' != 'true' And '$(AddRazorSupportForMvc)' == '' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' >= '3.0'">true</AddRazorSupportForMvc>

<!-- Trimmer defaults that depend on user-definable settings -->
<SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == '' And '$(TrimmerDefaultAction)' != 'link'">true</SuppressTrimAnalysisWarnings>
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk.Razor" Project="Sdk.targets" />
Expand Down

0 comments on commit 23e7fd3

Please sign in to comment.