Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc98af89

Browse files
authored
Build w/ VS 2019; restore w/msbuild (#375)
- 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 parentfeb9b13 commitc98af89

File tree

12 files changed

+65
-51
lines changed

12 files changed

+65
-51
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 -equals 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 & 19 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,24 +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 -Verbosity quiet' />
81-
<MSBuild Projects="@(_ProjectsToRestore)" Targets="Restore"
82-
BuildInParallel="$(BuildInParallel)"
83-
Condition=" '$(BuildPortable)' == 'true' "
84-
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="" />
8574
</Target>
8675

8776
<!-- Pick the right Microsoft.Web.FxCop package to use and copy it to a standard location. -->
@@ -96,7 +85,7 @@
9685
Properties="Configuration=Release;OutputPath=$(CustomFxCopRulesPath)" />
9786
</Target>
9887

99-
<Target Name="Build" DependsOnTargets="RestorePackages;BuildTools">
88+
<Target Name="Build" DependsOnTargets="RestoreSkipStrongNames;RestorePackages;BuildTools">
10089
<!-- we need to batch the solution files since they both build Microsoft.TestCommon -->
10190
<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)." />
10291
<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
setvswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
1413
ifnotexist%vswhere% (
15-
setVsWhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
14+
setvswhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
1615
)
1716
ifnotexist%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 2.1.500 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
setInstallDir=
29-
for /f"usebackq tokens=*"%%iin (`%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=*"%%iin (`%vswhere% -version16 -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-
setInstallDir=%%i
35+
setInstallDir="%%i"
3336
)
34-
ifexist"%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
35-
setMSBuild="%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe"
37+
38+
ifexist%InstallDir%\MSBuild\Current\Bin\MSBuild.exe (
39+
setMSBuild=%InstallDir%\MSBuild\Current\Bin\MSBuild.exe
3640
)else (
37-
echo Could not find MSBuild.exe. Please install theVS2017 BuildTools component or a workload that includes it.
41+
echo Could not find MSBuild.exe. Please install theVS2019 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
REM Are we running in a local dev environment (not on CI)?
4251
ifDEFINED CI (set Desktop=false)elseifDEFINED TEAMCITY_VERSION (set Desktop=false)else (set Desktop=true)
4352

‎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
<IncludeAllAction="Error" />
77
<RulesAnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis"RuleNamespace="Microsoft.Rules.Managed">
88
<RuleId="CA1062"Action="None" />
9+
<!-- Ignore int.ToString(...) calls w/o an IFormatProvider in old code.-->
10+
<RuleId="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
<ImportProject="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
277-
<ImportProject="..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets" />
270+
<ImportProject="..\..\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+
<TargetName="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+
<ErrorCondition="!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
<ImportProject="..\Directory.Build.targets" />
3-
<ImportProject="..\packages\**\xunit.runner.msbuild.props" />
3+
<ImportProject="..\packages\xunit.runner.msbuild.2.3.1\**\xunit.runner.msbuild.props" />
44

55
<TargetName="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
<AnalyzerInclude="..\..\packages\xunit.analyzers.0.7.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
318318
</ItemGroup>
319319
<ImportProject="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
320-
<ImportProject="..\..\packages\Microsoft.Bcl.Build.1.0.8\tools\Microsoft.Bcl.Build.targets" />
320+
<ImportProject="..\..\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+
<ImportProject="..\..\packages\xunit.core.2.3.0\build\xunit.core.targets"
323+
Condition="Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.targets')" />
321324
<TargetName="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-
<ErrorCondition="!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-
<ErrorCondition="!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-
<ErrorCondition="!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+
<ErrorCondition="!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+
<ErrorCondition="!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+
<ErrorCondition="!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+
<ErrorCondition="!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-
<ImportProject="..\..\packages\xunit.core.2.3.0\build\xunit.core.targets"Condition="Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.targets')" />
330337
</Project>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp