Skip to content
Permalink
Browse files

Fix our MSB3270 warnings

There are a few parts to this change:

1. Ensure that MSB3270 and MSB3277 warnings are promoted to errors in CI
and hence block merging.
1. Move our DiaSymReader.Native logic into a separate targets file.
This resource cannot be consumed with a simple package reference but
rather requires a package reference and custom logic to pull out the
contained binaries. This logic used to be spread through our build. Now
it's in a single place.
1. Remove the x86 bootstrapping logic. This was testing a pretty obscure
scenario and the cost of maintaining that logic is siginificant at this
point. Can bring back if we ever find a bug in this area.

The root cause of the MSB3270 warnings is a subtle change in the SDK. It
now passes the runtime graph to NuGet for native assets. In the case of
DiaSymReader.Native there are runtime specific assets hence the SDK /
NuGet had to pick one for framework projects. This eventually lead to
`PlatformTarget` being set to x86 where it shoud have been AnyCPU.

Part of the change includes adding `ExcludeAssets=all` to the package
reference which means they no longer figure into this logic and hence
the binaries are marked as AnyCPU.

This regression in behavior is being tracked by
dotnet/sdk#3495
  • Loading branch information...
jaredpar committed Jul 31, 2019
1 parent baa0dcc commit e75dd56e25b63af1fc175f1abae8a56119c880a5
@@ -37,7 +37,7 @@ jobs:
timeoutInMinutes: 90

steps:
- script: eng/cibuild.cmd -configuration $(_configuration) -prepareMachine -testDesktop -$(_testKind) -procdump
- script: eng/cibuild.cmd -configuration $(_configuration) -prepareMachine -testDesktop -$(_testKind) -procdump -warnAsError
displayName: Build and Test

- task: PublishTestResults@2
@@ -279,7 +279,7 @@ function Make-BootstrapBuild([switch]$force32 = $false) {
$projectPath = "src\NuGet\$packageName\$packageName.Package.csproj"
$force32Flag = if ($force32) { " /p:BOOTSTRAP32=true" } else { "" }

Run-MSBuild $projectPath "/restore /t:Pack /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP /p:PackageOutputPath=`"$dir`" /p:EnableNgenOptimization=false $force32Flag" -logFileName "Bootstrap" -configuration $bootstrapConfiguration
Run-MSBuild $projectPath "/restore /t:Pack /p:RoslynEnforceCodeStyle=false /p:UseRoslynAnalyzers=false /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP /p:PackageOutputPath=`"$dir`" /p:EnableNgenOptimization=false $force32Flag" -logFileName "Bootstrap" -configuration $bootstrapConfiguration
$packageFile = Get-ChildItem -Path $dir -Filter "$packageName.*.nupkg"
Unzip "$dir\$packageFile" $dir

@@ -222,14 +222,18 @@ function BuildSolution() {
# Do not set this property to true explicitly, since that would override values set in projects.
$suppressExtensionDeployment = if (!$deployExtensions) { "/p:DeployExtension=false" } else { "" }

# The warnAsError flag for MSBuild will promote all warnings to errors. This is true for warnings
# that MSBuild output as well as ones that custom tasks output. This causes problems for us as
# portions of our build will issue warnings: style analyzers being the most prominent example. Hence
# rather than a blanket include of warnings we include a fixed set.
#
# In all cases we pass /p:TreatWarningsAsErrors=true to promote compiler warnings to errors
$msbuildWarnAsError = if ($warnAsError) { "/warnAsError:MSB3270,MSB3277" } else { "" }

# Workaround for some machines in the AzDO pool not allowing long paths (%5c is msbuild escaped backslash)
$ibcDir = Join-Path $RepoRoot ".o%5c"

try {
# Setting /p:TreatWarningsAsErrors=true is a workaround for https://github.com/Microsoft/msbuild/issues/3062.
# We don't pass /warnaserror to msbuild ($warnAsError is set to $false by default above), but set
# /p:TreatWarningsAsErrors=true so that compiler reported warnings, other than IDE0055 are treated as errors.
# Warnings reported from other msbuild tasks are not treated as errors for now.
MSBuild $toolsetBuildProj `
$bl `
/p:Configuration=$configuration `
@@ -253,6 +257,7 @@ function BuildSolution() {
/p:EnableNgenOptimization=$applyOptimizationData `
/p:IbcOptimizationDataDir=$ibcDir `
$suppressExtensionDeployment `
$msbuildWarnAsError `
@properties
}
finally {
@@ -0,0 +1,21 @@
<Project>

<PropertyGroup>
<PlatformTarget Condition="'$(PlatformTarget)' == ''">AnyCPU</PlatformTarget>
</PropertyGroup>

<ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true'">
<Content Include="$(NuGetPackageRoot)\microsoft.diasymreader.native\$(MicrosoftDiaSymReaderNativeVersion)\runtimes\win\native\Microsoft.DiaSymReader.Native.x86.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
<Content Include="$(NuGetPackageRoot)\microsoft.diasymreader.native\$(MicrosoftDiaSymReaderNativeVersion)\runtimes\win\native\Microsoft.DiaSymReader.Native.amd64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>

<PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativeVersion)" ExcludeAssets="all"/>
</ItemGroup>
</Project>
@@ -18,12 +18,6 @@
which has all of our global settings
-->
<UserRuntimeConfig Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(OutputType)' == 'Exe'">$(RepositoryEngineeringDir)config\runtimeconfig.template.json</UserRuntimeConfig>

<!--
Bootstrap compiler should run as a 32 bit process on our 32 bit test runs. This will validate
the legacy JIT ability to handle the compiler.
-->
<PlatformTarget Condition="'$(OutputType)' == 'Exe' AND '$(TargetFramework)' == 'net472' AND '$(BOOTSTRAP32)' == 'true'">x86</PlatformTarget>
</PropertyGroup>

<ItemGroup Condition="'$(Language)' == 'CSharp' and '$(TargetFramework)' == 'net20'">
@@ -18,7 +18,6 @@
<ProjectReference Include="..\Portable\Microsoft.CodeAnalysis.CSharp.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativeVersion)" Condition="'$(DotNetBuildFromSource)' != 'true'" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
</ItemGroup>
<ItemGroup>
@@ -42,4 +41,5 @@
</None>
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="$(RepositoryEngineeringDir)targets\DiaSymReaderNative.targets" />
</Project>
@@ -19,18 +19,6 @@
Do not install this package manually, it will be added as a prerequisite by other packages that require it.
</PackageDescription>
</PropertyGroup>
<ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true'">
<Content Include="$(NuGetPackageRoot)\microsoft.diasymreader.native\$(MicrosoftDiaSymReaderNativeVersion)\runtimes\win\native\Microsoft.DiaSymReader.Native.x86.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
<Content Include="$(NuGetPackageRoot)\microsoft.diasymreader.native\$(MicrosoftDiaSymReaderNativeVersion)\runtimes\win\native\Microsoft.DiaSymReader.Native.amd64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\DesktopShim.cs" />
<Compile Update="CodeAnalysisResources.Designer.cs">
@@ -48,8 +36,6 @@
will import everything but content files from Microsoft.CodeAnalysis.Analyzers, specifically, analyzers.
-->
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="$(MicrosoftCodeAnalysisAnalyzersVersion)" Condition="'$(DotNetBuildFromSource)' != 'true'" PrivateAssets="ContentFiles" />

<PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativeVersion)" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
@@ -21,7 +21,6 @@
<ItemGroup>
<Reference Include="System.Configuration" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
<PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativeVersion)" Condition="'$(DotNetBuildFromSource)' != 'true'" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\RuntimeHostInfo.cs" />
@@ -43,4 +42,5 @@
<InternalsVisibleTo Include="VBCSCompiler.UnitTests" />
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="$(RepositoryEngineeringDir)targets\DiaSymReaderNative.targets" />
</Project>
@@ -17,7 +17,6 @@
<ProjectReference Include="..\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativeVersion)" Condition="'$(DotNetBuildFromSource)' != 'true'" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
</ItemGroup>
<ItemGroup>
@@ -41,4 +40,5 @@
</None>
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="$(RepositoryEngineeringDir)targets\DiaSymReaderNative.targets" />
</Project>
@@ -31,4 +31,5 @@
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)targets\DiaSymReaderNative.targets" />
</Project>
@@ -31,6 +31,8 @@
<DesktopCompilerArtifact Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Scripting\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Scripting.dll" NgenArchitecture="all" NgenApplication="csi.exe"/>
<DesktopCompilerArtifact Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.Scripting\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.CSharp.Scripting.dll" NgenArchitecture="all" NgenApplication="csi.exe"/>
<DesktopCompilerArtifact Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.VisualBasic.dll" NgenArchitecture="all" NgenApplication="VBCSCompiler.exe"/>
<DesktopCompilerArtifact Include="$(ArtifactsBinDir)csc\$(Configuration)\net472\Microsoft.DiaSymReader.Native.amd64.dll"/>
<DesktopCompilerArtifact Include="$(ArtifactsBinDir)csc\$(Configuration)\net472\Microsoft.DiaSymReader.Native.x86.dll"/>
<DesktopCompilerArtifact Include="$(ArtifactsBinDir)csc\$(Configuration)\net472\csc.exe" NgenArchitecture="all" NgenApplication="csc.exe" NgenPriority="2"/>
<DesktopCompilerArtifact Include="$(ArtifactsBinDir)csc\$(Configuration)\net472\csc.exe.config"/>
<DesktopCompilerArtifact Include="$(ArtifactsBinDir)csc\$(Configuration)\net472\csc.rsp"/>
@@ -33,7 +33,6 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ResultProvider.UnitTests" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativeVersion)" />
<PackageReference Include="Microsoft.DiaSymReader" Version="$(MicrosoftDiaSymReaderVersion)" />
<PackageReference Include="Microsoft.DiaSymReader.PortablePdb" Version="$(MicrosoftDiaSymReaderPortablePdbVersion)" />
<PackageReference Include="Microsoft.DiaSymReader.Converter" Version="$(MicrosoftDiaSymReaderConverterVersion)" />
@@ -64,4 +63,5 @@
</ReferencePath>
</ItemGroup>
</Target>
<Import Project="$(RepositoryEngineeringDir)targets\DiaSymReaderNative.targets" />
</Project>

0 comments on commit e75dd56

Please sign in to comment.
You can’t perform that action at this time.