Skip to content

Commit d87e6e6

Browse files
committed
Build w/ VS 2019; restore w/ msbuild
- handle both SDK-style and legacy projects in one way - set `$(RestorePackagesConfig)` to cover both project types - allow newer .NET SDKs to align w/ VS components - make a few `<import/>`s conditional to avoid problems in `Restore` target evaluation - restore global packages.config before building to make StyleCop available - move second copies of packages.config packages into packages/ folder - update FxCop TFM - .NET 4.0 not supported because current FxCopSdk is built against .NET 4.7.2 - suppress new warnings about old FxCop approach and not using `IFormatProvider`
1 parent 3e2e11b commit d87e6e6

File tree

12 files changed

+65
-52
lines changed

12 files changed

+65
-52
lines changed

.codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
displayName: CodeQL
4444
pool:
4545
name: NetCore1ESPool-Internal
46-
demands: ImageOverride -equals windows.vs2017.amd64
46+
demands: ImageOverride -equal windows.vs2019.amd64
4747
timeoutInMinutes: 90
4848

4949
steps:

Directory.Build.props

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
<PropertyGroup>
55
<!-- Require VS2017 so VS builds also use MSBuild v15.0. -->
6-
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
6+
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
7+
<!--
8+
Suppress "MSBUILD : warning : Post-build Code Analysis (FxCopCmd.exe) has been deprecated in favor of FxCop
9+
analyzers, which run during build. Refer to https://aka.ms/fxcopanalyzers to migrate to FxCop analyzers."
10+
-->
11+
<SuppressLegacyCodeAnalysisDeprecatedWarning>true</SuppressLegacyCodeAnalysisDeprecatedWarning>
712
</PropertyGroup>
813
</Project>

Runtime.msbuild

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<BuildPortable Condition=" '$(BuildPortable)' == '' ">true</BuildPortable>
1212
<BuildInParallel Condition=" '$(BuildInParallel)' == '' And $(MSBuildNodeCount) &gt; 1 ">true</BuildInParallel>
1313
<BuildInParallel Condition=" '$(BuildInParallel)' == '' ">false</BuildInParallel>
14+
<RestoreInParallel Condition=" '$(RestoreInParallel)' == '' ">false</RestoreInParallel>
1415
<TestInParallel Condition=" '$(TestInParallel)' == '' ">false</TestInParallel>
1516
<TestResultsDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\test\TestResults\</TestResultsDirectory>
1617
<SkipStrongNamesExe>$(MSBuildThisFileDirectory)packages\Microsoft.Web.SkipStrongNames.1.0.0\tools\SkipStrongNames.exe</SkipStrongNamesExe>
@@ -64,25 +65,12 @@
6465
</Target>
6566

6667
<Target Name="RestorePackages" DependsOnTargets="DownloadNuGet">
67-
<ItemGroup>
68-
<_NuGetPackagesAndSolutions Include="Runtime.sln" />
69-
70-
<!-- Avoid restoring RuntimePortable.sln directly. -->
71-
<_NuGetPackagesAndSolutions Include="src\System.Net.Http.Formatting.NetCore\packages.config;
72-
test\System.Net.Http.Formatting.NetCore.Test\packages.config"
73-
Condition=" '$(BuildPortable)' == 'true' " />
74-
<_ProjectsToRestore Include="test\System.Net.Http.Formatting.NetStandard.Test\System.Net.Http.Formatting.NetStandard.Test.csproj"
75-
Condition=" '$(BuildPortable)' == 'true' " />
76-
</ItemGroup>
77-
78-
<Message Text="Restoring NuGet packages..." Importance="High" />
79-
<Exec Command='"$(NuGetExe)" restore "%(_NuGetPackagesAndSolutions.Identity)" ^
80-
-PackagesDirectory packages -NonInteractive ^
81-
-Verbosity quiet -ConfigFile "$(MSBuildThisFileDirectory)\.nuget\NuGet.Config"' />
82-
<MSBuild Projects="@(_ProjectsToRestore)" Targets="Restore"
83-
BuildInParallel="$(BuildInParallel)"
84-
Condition=" '$(BuildPortable)' == 'true' "
85-
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);VisualStudioVersion=$(VisualStudioVersion)" />
68+
<Message Text="%0ARestoring NuGet packages..." Importance="High" />
69+
<MSBuild Projects="@(SolutionsToBuild)" Targets="Restore"
70+
BuildInParallel="$(RestoreInParallel)"
71+
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
72+
RestorePackagesConfig=true;VisualStudioVersion=$(VisualStudioVersion)" />
73+
<Message Importance="High" Text="" />
8674
</Target>
8775

8876
<!-- Pick the right Microsoft.Web.FxCop package to use and copy it to a standard location. -->
@@ -97,7 +85,7 @@
9785
Properties="Configuration=Release;OutputPath=$(CustomFxCopRulesPath)" />
9886
</Target>
9987

100-
<Target Name="Build" DependsOnTargets="RestorePackages;BuildTools">
88+
<Target Name="Build" DependsOnTargets="RestoreSkipStrongNames;RestorePackages;BuildTools">
10189
<!-- we need to batch the solution files since they both build Microsoft.TestCommon -->
10290
<Error Condition=" '$(CodeAnalysis)' == 'true' and '$(Configuration)' == 'Release' " Text="Unable to run code analysis in Release configuration. Release assemblies do not include SuppressMessage attributes (so code analysis would always fail with the errors that are normally suppressed)." />
10391
<MakeDir Directories="bin\$(Configuration)" />

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727
pool:
2828
${{ if eq(variables['System.TeamProject'], 'public') }}:
2929
name: NetCore-Public
30-
demands: ImageOverride -equals windows.vs2017.amd64.open
30+
demands: ImageOverride -equals windows.vs2019.amd64.open
3131
${{ else }}:
3232
name: NetCore1ESPool-Internal
33-
demands: ImageOverride -equals windows.vs2017.amd64
33+
demands: ImageOverride -equals windows.vs2019.amd64
3434
timeoutInMinutes: 30
3535

3636
strategy:

build.cmd

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ mkdir bin
77

88
:Build
99

10-
REM Find the most recent 32bit MSBuild.exe on the system. Require v15.0 (installed with VS2017) or later since .NET
11-
REM Core projects are coming soon.
12-
REM Use `vswhere` for the search since %ProgramFiles(x86)%\msbuild\15.0\Bin\MSBuild.exe almost never exists.
10+
REM Find the most recent 32bit MSBuild.exe on the system. Require v16.0 (installed with VS2019) or later.
11+
REM Use `vswhere` for the search because it can find all VS installations.
1312
set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
1413
if not exist %vswhere% (
15-
set VsWhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
14+
set vswhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
1615
)
1716
if not exist %vswhere% (
1817
REM vswhere.exe not in normal locations; check the Path.
@@ -25,19 +24,29 @@ if not exist %vswhere% (
2524
goto BuildFail
2625
)
2726

27+
REM We're fine w/ any .NET SDK newer than 3.1.0 but also need a 2.1.x runtime. Microsoft.Net.Core.Component.SDK.2.1
28+
REM actually checks for only the runtime these days.
2829
set InstallDir=
29-
for /f "usebackq tokens=*" %%i in (`%vswhere% -version ^[15^,16^) -latest -prerelease -products * ^
30-
-requires Microsoft.Component.MSBuild -requires Microsoft.Net.Core.Component.SDK.2.1 ^
30+
for /f "usebackq tokens=*" %%i in (`%vswhere% -version 16 -latest -prerelease -products * ^
31+
-requires Microsoft.Component.MSBuild ^
32+
-requires Microsoft.NetCore.Component.SDK ^
33+
-requires Microsoft.Net.Core.Component.SDK.2.1 ^
3134
-property installationPath`) do (
32-
set InstallDir=%%i
35+
set InstallDir="%%i"
3336
)
34-
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
35-
set MSBuild="%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe"
37+
38+
if exist %InstallDir%\MSBuild\Current\Bin\MSBuild.exe (
39+
set MSBuild=%InstallDir%\MSBuild\Current\Bin\MSBuild.exe
3640
) else (
37-
echo Could not find MSBuild.exe. Please install the VS2017 BuildTools component or a workload that includes it.
41+
echo Could not find MSBuild.exe. Please install the VS2019 BuildTools component or a workload that includes it.
3842
goto BuildFail
3943
)
4044

45+
REM Configure NuGet operations to work w/in this repo i.e. do not pollute system packages folder.
46+
REM Note this causes two copies of packages restored using packages.config to land in this folder e.g.
47+
REM StyleCpy.5.0.0/ and stylecop/5.0.0/.
48+
set "NUGET_PACKAGES=%CD%\packages"
49+
4150
if "%1" == "" goto BuildDefaults
4251

4352
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M ^

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
33
"version": "2.1.500",
4-
"rollForward": "latestPatch"
4+
"rollForward": "major"
55
}
66
}

src/Strict.ruleset

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
<IncludeAll Action="Error" />
77
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
88
<Rule Id="CA1062" Action="None" />
9+
<!-- Ignore int.ToString(...) calls w/o an IFormatProvider in old code. -->
10+
<Rule Id="CA1305" Action="None" />
911
</Rules>
1012
</RuleSet>

src/System.Net.Http.Formatting.NetCore/System.Net.Http.Formatting.NetCore.csproj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,14 @@
266266
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.13\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Primitives.dll</HintPath>
267267
</Reference>
268268
</ItemGroup>
269-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
270-
Other similar extension points exist, see Microsoft.Common.targets.
271-
<Target Name="BeforeBuild">
272-
</Target>
273-
<Target Name="AfterBuild">
274-
</Target>
275-
-->
276269
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
277-
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets" />
270+
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets"
271+
Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets')" />
272+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
273+
<PropertyGroup>
274+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
275+
</PropertyGroup>
276+
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets')"
277+
Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets'))" />
278+
</Target>
278279
</Project>

test/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<Import Project="..\Directory.Build.targets" />
3-
<Import Project="..\packages\**\xunit.runner.msbuild.props" />
3+
<Import Project="..\packages\xunit.runner.msbuild.2.3.1\**\xunit.runner.msbuild.props" />
44

55
<Target Name="Test" DependsOnTargets="_TestWithVSTest;_TestWithDotnetTest;_TestWithRunner" />
66

test/System.Net.Http.Formatting.NetCore.Test/System.Net.Http.Formatting.NetCore.Test.csproj

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,21 @@
317317
<Analyzer Include="..\..\packages\xunit.analyzers.0.7.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
318318
</ItemGroup>
319319
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
320-
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets" />
320+
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets"
321+
Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets')" />
322+
<Import Project="..\..\packages\xunit.core.2.3.0\build\xunit.core.targets"
323+
Condition="Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.targets')" />
321324
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
322325
<PropertyGroup>
323326
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
324327
</PropertyGroup>
325-
<Error Condition="!Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.3.0\build\xunit.core.props'))" />
326-
<Error Condition="!Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.3.0\build\xunit.core.targets'))" />
327-
<Error Condition="!Exists('..\..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props'))" />
328+
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets')"
329+
Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets'))" />
330+
<Error Condition="!Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.props')"
331+
Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.3.0\build\xunit.core.props'))" />
332+
<Error Condition="!Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.targets')"
333+
Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.3.0\build\xunit.core.targets'))" />
334+
<Error Condition="!Exists('..\..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')"
335+
Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props'))" />
328336
</Target>
329-
<Import Project="..\..\packages\xunit.core.2.3.0\build\xunit.core.targets" Condition="Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.targets')" />
330337
</Project>

tools/WebStack.StyleCop.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<ItemGroup>
3-
<StyleCopMsBuildRunner Include="$(WebStackRootPath)packages\**\StyleCop.dll"/>
4-
<StyleCopAdditionalAddins Include="$(WebStackRootPath)packages\**\Microsoft.Web.StyleCop.dll" />
3+
<StyleCopMsBuildRunner Include="$(WebStackRootPath)packages\StyleCop.5.0.0\**\StyleCop.dll"/>
4+
<StyleCopAdditionalAddins Include="$(WebStackRootPath)packages\Microsoft.Web.SkipStrongNames.1.0.0\**\Microsoft.Web.StyleCop.dll" />
55
<StyleCopAdditionalAddinPaths Include="@(StyleCopAdditionalAddins -> '%(RootDir)%(Directory)')" />
66
</ItemGroup>
77

tools/src/Microsoft.Web.FxCop/Microsoft.Web.FxCop.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>Microsoft.Web.FxCop</RootNamespace>
1212
<AssemblyName>Microsoft.Web.FxCop</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<!-- May need to be updated as FxCopSdk.dll is migrated to newer TFMs. -->
14+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1415
<OutputPath Condition=" '$(OutputPath)' == '' ">bin\$(Configuration)</OutputPath>
1516
</PropertyGroup>
1617
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

0 commit comments

Comments
 (0)