Skip to content

Commit d786608

Browse files
committed
Add Microsoft.AspNetCore.BuildTools.ApiCheck to builds
- aspnet/KoreBuild#143 Add Microsoft.AspNetCore.BuildTools.ApiCheck.Task project - include task assembly in the Microsoft.AspNetMicrosoft.AspNetCore.BuildTools.ApiCheck package - add *.props and *.targets files to hook task into `Pack` target; runs just before .nupkg is created - reference Microsoft.AspNetMicrosoft.AspNetCore.BuildTools.ApiCheck project from the Sdk project - requires lots of hacks; dotnet/sdk#939 workarounds fail in this scenario - bump ApiCheck package version Improve project-to-project reference and native assembly handling - avoid `FileNotFoundException` in `AssemblyLoadContext.GetAssemblyName()` due to `\placeholder\` paths - catch and ignore `BadImageFormatException` in `AssemblyLoadContext.GetAssemblyName()` - avoid `InvalidOperationException` in `PackageGraph.RuntimeIsCompatible()` due to missing .sha512 file Fall back to `RuntimeTargets` when `RuntimeAssemblies` yields no assemblies Change ApiCheck.exe's options and output - add `api-check --compact-output` option - generally make tool's output more useful to the task - catch and log `FileNotFoundException`; output types and stack traces of caught `Exception`s - change ApiCheck.exe option from `--ApiListing` to `--api-listing` for consistency w/ other options Use Microsoft.Extensions.CommandLineUtils.Sources package - VersionTool project cannot do this because it has `public` properties of these `internal` types Update appveyor.yml now that VS 2017 RC image is no more nits: - remove `PackageGraph.RuntimeIsCompatible()` `candidateRuntime` parameter - not needed and confusingly-named; passed value included in `compatibleRuntimes` - update solution to use current project type GUID - ignore global.json and launchSettings.json - make some Linq a bit more readable - whitespace and `using` cleanup - move all property groups above item groups in Microsoft.AspNetMicrosoft.AspNetCore.BuildTools.ApiCheck.csproj - make a couple of constructors `private`; used only in `public static` methods - ignore case a bit more - remove duplicate `<PropertyGroup>` from `NugetReferenceResolver` project - get this repo building on Linux - don't need API checks in this repo - centralize a few more properties in dependencies.props notes: - don't use `UseCommandProcessor==true`; `ToolTask` writes out .cmd file with a BOM that cmd.exe hates
1 parent e405875 commit d786608

32 files changed

+539
-115
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ project.lock.json
1919
.build
2020
.vs/
2121
.vscode/
22+
global.json
23+
launchSettings.json

BuildTools.sln

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,37 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1515
EndProject
1616
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{60A938B2-D95A-403C-AA7A-3683AD64DFA0}"
1717
EndProject
18-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetPackageVerifier", "src\NuGetPackageVerifier\NuGetPackageVerifier.csproj", "{657AFF5E-164E-493D-8501-8026B7C20808}"
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGetPackageVerifier", "src\NuGetPackageVerifier\NuGetPackageVerifier.csproj", "{657AFF5E-164E-493D-8501-8026B7C20808}"
1919
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SplitPackages", "src\SplitPackages\SplitPackages.csproj", "{C98F7832-85FB-451B-9152-87425ACF8EEB}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SplitPackages", "src\SplitPackages\SplitPackages.csproj", "{C98F7832-85FB-451B-9152-87425ACF8EEB}"
2121
EndProject
22-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependenciesPackager", "src\DependenciesPackager\DependenciesPackager.csproj", "{183BBD52-FFC3-4636-9C6F-EAFA5CDBFEAB}"
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependenciesPackager", "src\DependenciesPackager\DependenciesPackager.csproj", "{183BBD52-FFC3-4636-9C6F-EAFA5CDBFEAB}"
2323
EndProject
24-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageClassifier", "src\PackageClassifier\PackageClassifier.csproj", "{5F13329B-48C4-418A-A495-E9F58949C43E}"
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PackageClassifier", "src\PackageClassifier\PackageClassifier.csproj", "{5F13329B-48C4-418A-A495-E9F58949C43E}"
2525
EndProject
26-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersionTool", "src\VersionTool\VersionTool.csproj", "{102216C8-55CB-49EA-B20E-D41B1F0E42B1}"
26+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VersionTool", "src\VersionTool\VersionTool.csproj", "{102216C8-55CB-49EA-B20E-D41B1F0E42B1}"
2727
EndProject
28-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiCheckBaseline.V1", "test\ApiCheckBaseline.V1\ApiCheckBaseline.V1.csproj", "{1B1731E0-4ADB-4A04-9418-FCD7F5CFB79E}"
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiCheckBaseline.V1", "test\ApiCheckBaseline.V1\ApiCheckBaseline.V1.csproj", "{1B1731E0-4ADB-4A04-9418-FCD7F5CFB79E}"
2929
EndProject
30-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiCheckBaseline.V2", "test\ApiCheckBaseline.V2\ApiCheckBaseline.V2.csproj", "{ECA89839-3332-43F3-B1B1-9C2D91B7285E}"
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiCheckBaseline.V2", "test\ApiCheckBaseline.V2\ApiCheckBaseline.V2.csproj", "{ECA89839-3332-43F3-B1B1-9C2D91B7285E}"
3131
EndProject
32-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiCheck.Test", "test\ApiCheck.Test\ApiCheck.Test.csproj", "{D61A892B-D214-44AB-9652-334C4338377B}"
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiCheck.Test", "test\ApiCheck.Test\ApiCheck.Test.csproj", "{D61A892B-D214-44AB-9652-334C4338377B}"
3333
EndProject
34-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.BuildTools.ApiCheck", "src\Microsoft.AspNetCore.BuildTools.ApiCheck\Microsoft.AspNetCore.BuildTools.ApiCheck.csproj", "{AEFC7985-27C8-468E-8EF8-E1D589C9053F}"
34+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.BuildTools.ApiCheck", "src\Microsoft.AspNetCore.BuildTools.ApiCheck\Microsoft.AspNetCore.BuildTools.ApiCheck.csproj", "{AEFC7985-27C8-468E-8EF8-E1D589C9053F}"
3535
EndProject
36-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetPackageVerifier.Task", "src\NuGetPackageVerifier.Task\NuGetPackageVerifier.Task.csproj", "{EF38C1CA-8A2E-4C8E-B478-7072C0140514}"
36+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGetPackageVerifier.Task", "src\NuGetPackageVerifier.Task\NuGetPackageVerifier.Task.csproj", "{EF38C1CA-8A2E-4C8E-B478-7072C0140514}"
3737
EndProject
38-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Internal.AspNetCore.Sdk", "src\Internal.AspNetCore.Sdk\Internal.AspNetCore.Sdk.csproj", "{F0E4CF2B-29B9-432B-BF27-195996CA24FD}"
38+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Internal.AspNetCore.Sdk", "src\Internal.AspNetCore.Sdk\Internal.AspNetCore.Sdk.csproj", "{F0E4CF2B-29B9-432B-BF27-195996CA24FD}"
3939
EndProject
40-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Internal.AspNetCore.BuildTools.Tasks", "src\Internal.AspNetCore.BuildTools.Tasks\Internal.AspNetCore.BuildTools.Tasks.csproj", "{6A631446-BBDD-4743-B576-7F9793B6BE45}"
40+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Internal.AspNetCore.BuildTools.Tasks", "src\Internal.AspNetCore.BuildTools.Tasks\Internal.AspNetCore.BuildTools.Tasks.csproj", "{6A631446-BBDD-4743-B576-7F9793B6BE45}"
4141
EndProject
42-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildTools.Tasks.Tests", "test\BuildTools.Tasks.Tests\BuildTools.Tasks.Tests.csproj", "{211858CA-6E82-4EFD-9960-8D023EEB789F}"
42+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildTools.Tasks.Tests", "test\BuildTools.Tasks.Tests\BuildTools.Tasks.Tests.csproj", "{211858CA-6E82-4EFD-9960-8D023EEB789F}"
4343
EndProject
4444
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NugetReferenceResolver", "src\NugetReferenceResolver\NugetReferenceResolver.csproj", "{7034433C-4D1B-44A9-B696-55F1C43DB8CB}"
4545
EndProject
4646
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackagePublisher", "src\PackagePublisher\PackagePublisher.csproj", "{E072CD5C-C8D9-4724-9896-A31973775C09}"
4747
EndProject
48-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackagePublisher", "src\PackagePublisher\PackagePublisher.csproj", "{E072CD5C-C8D9-4724-9896-A31973775C09}"
48+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.BuildTools.ApiCheck.Task", "src\Microsoft.AspNetCore.BuildTools.ApiCheck.Task\Microsoft.AspNetCore.BuildTools.ApiCheck.Task.csproj", "{9BE633D2-025A-4B29-A8A9-FC8F79C331AB}"
4949
EndProject
5050
Global
5151
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -113,6 +113,10 @@ Global
113113
{E072CD5C-C8D9-4724-9896-A31973775C09}.Debug|Any CPU.Build.0 = Debug|Any CPU
114114
{E072CD5C-C8D9-4724-9896-A31973775C09}.Release|Any CPU.ActiveCfg = Release|Any CPU
115115
{E072CD5C-C8D9-4724-9896-A31973775C09}.Release|Any CPU.Build.0 = Release|Any CPU
116+
{9BE633D2-025A-4B29-A8A9-FC8F79C331AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
117+
{9BE633D2-025A-4B29-A8A9-FC8F79C331AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
118+
{9BE633D2-025A-4B29-A8A9-FC8F79C331AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
119+
{9BE633D2-025A-4B29-A8A9-FC8F79C331AB}.Release|Any CPU.Build.0 = Release|Any CPU
116120
EndGlobalSection
117121
GlobalSection(SolutionProperties) = preSolution
118122
HideSolutionNode = FALSE
@@ -133,5 +137,6 @@ Global
133137
{211858CA-6E82-4EFD-9960-8D023EEB789F} = {60A938B2-D95A-403C-AA7A-3683AD64DFA0}
134138
{7034433C-4D1B-44A9-B696-55F1C43DB8CB} = {A4F4353B-C3D2-40B0-909A-5B48A748EA76}
135139
{E072CD5C-C8D9-4724-9896-A31973775C09} = {A4F4353B-C3D2-40B0-909A-5B48A748EA76}
140+
{9BE633D2-025A-4B29-A8A9-FC8F79C331AB} = {A4F4353B-C3D2-40B0-909A-5B48A748EA76}
136141
EndGlobalSection
137142
EndGlobal

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ build_script:
1111
clone_depth: 1
1212
test: off
1313
deploy: off
14-
os: Visual Studio 2017 RC
14+
os: Visual Studio 2017

build/common.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
<PropertyGroup>
66
<!-- these imports substitute for a package reference to Internal.AspNetCore.Sdk -->
7-
<_AspNetToolsSdkPath>$([MSBuild]::GetDirectoryNameOfFileAbove($(MsBuildThisFileDirectory), NuGet.config))\src\Internal.AspNetCore.Sdk</_AspNetToolsSdkPath>
7+
<_AspNetToolsSdkPath>$([MSBuild]::GetDirectoryNameOfFileAbove($(MsBuildThisFileDirectory), NuGet.Config))\src\Internal.AspNetCore.Sdk</_AspNetToolsSdkPath>
88
<CustomAfterMicrosoftCommonTargets>$(_AspNetToolsSdkPath)\build\Internal.AspNetCore.Sdk.targets</CustomAfterMicrosoftCommonTargets>
99
<CustomAfterMicrosoftCommonCrossTargetingTargets>$(_AspNetToolsSdkPath)\buildMultiTargeting\Internal.AspNetCore.Sdk.targets</CustomAfterMicrosoftCommonCrossTargetingTargets>
1010
<GenerateCommitHashAttribute Condition="'$(CommitHash)'==''">false</GenerateCommitHashAttribute>
1111
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
12+
<EnableApiCheck>false</EnableApiCheck>
1213
</PropertyGroup>
1314

1415
<Import Project="$(_AspNetToolsSdkPath)\build\Internal.AspNetCore.Sdk.props" />

build/dependencies.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<Project>
22
<PropertyGroup>
3-
<AspNetCoreVersion>1.2.0-*</AspNetCoreVersion>
3+
<CommandLineUtilsVersion>1.2.0-*</CommandLineUtilsVersion>
4+
<CoreFxVersion>4.3.0</CoreFxVersion>
45
<DotNetCliUtilsVersion>1.0.1</DotNetCliUtilsVersion>
6+
<DotNetProjectModelVersion>1.0.0-rc3-1-003177</DotNetProjectModelVersion>
57
<JsonNetVersion>9.0.1</JsonNetVersion>
68
<MsBuildPackageVersions>15.1.548</MsBuildPackageVersions>
9+
<NetStandardPackageVersion>1.6.1</NetStandardPackageVersion>
710
<NuGetPackagesVersion>4.0.0</NuGetPackagesVersion>
811
<TestSdkVersion>15.0.0</TestSdkVersion>
912
<XunitVersion>2.2.0</XunitVersion>

src/DependenciesPackager/DependenciesPackager.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.0.0" />
13+
<PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(CommandLineUtilsVersion)" PrivateAssets="All" />
1414
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.0" />
1515
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.0" />
1616
<PackageReference Include="System.Diagnostics.Process" Version="4.1.0" />

src/Internal.AspNetCore.BuildTools.Tasks/Internal.AspNetCore.BuildTools.Tasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<PackageReference Include="Microsoft.Build.Framework" Version="$(MsBuildPackageVersions)" PrivateAssets="All" />
2626
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MsBuildPackageVersions)" PrivateAssets="All" />
2727
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MsBuildPackageVersions)" PrivateAssets="All" />
28-
<PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
28+
<PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(CommandLineUtilsVersion)" PrivateAssets="All" />
2929
</ItemGroup>
3030

3131
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6' ">

src/Internal.AspNetCore.Sdk/Internal.AspNetCore.Sdk.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Import Project="..\..\build\common.props" />
44

@@ -17,14 +17,17 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20+
<!-- Setting PrivateAssets to 'None' ensures the generated nuspec will include the build targets from this project -->
2021
<ProjectReference Include="..\Internal.AspNetCore.BuildTools.Tasks\Internal.AspNetCore.BuildTools.Tasks.csproj">
21-
<!-- Setting to 'None' ensures the generated nuspec will include the build targets from this project -->
22+
<PrivateAssets>None</PrivateAssets>
23+
</ProjectReference>
24+
<ProjectReference Include="..\Microsoft.AspNetCore.BuildTools.ApiCheck\Microsoft.AspNetCore.BuildTools.ApiCheck.csproj">
2225
<PrivateAssets>None</PrivateAssets>
2326
</ProjectReference>
2427
</ItemGroup>
2528

2629
<ItemGroup>
27-
<PackageReference Include="NETStandard.Library" Version="1.6.1" PrivateAssets="All" />
30+
<PackageReference Include="NETStandard.Library" Version="$(NetStandardPackageVersion)" PrivateAssets="All" />
2831
</ItemGroup>
2932

3033
</Project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!--
2+
WARNING: These targets are intended for building Microsoft's ASP.NET Core repos and are not intended
3+
for use outside of Microsoft.
4+
-->
5+
<Project>
6+
<Target Name="ApiCheck" Condition=" '$(EnableApiCheck)' == 'true' ">
7+
<PropertyGroup>
8+
<_ApiListingFileSuffix Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">net45.json</_ApiListingFileSuffix>
9+
<_ApiListingFileSuffix Condition=" '$(_ApiListingFileSuffix)' == '' ">netcore.json</_ApiListingFileSuffix>
10+
<_ApiListingFilePath>$(MSBuildProjectDirectory)\baseline.$(_ApiListingFileSuffix)</_ApiListingFilePath>
11+
<_ApiExclusionsFilePath>$(MSBuildProjectDirectory)\exceptions.$(_ApiListingFileSuffix)</_ApiExclusionsFilePath>
12+
<_ApiListingFile Condition=" Exists('$(_ApiListingFilePath)') ">$(_ApiListingFilePath)</_ApiListingFile>
13+
<_ApiExclusionsFile Condition=" Exists('$(_ApiExclusionsFilePath)') ">$(_ApiExclusionsFilePath)</_ApiExclusionsFile>
14+
</PropertyGroup>
15+
16+
<Message Condition=" '$(_ApiListingFile)' != '' "
17+
Importance="normal"
18+
Text="Checking for breaking changes in $(MSBuildProjectName), $(TargetFramework)" />
19+
<ApiCheckTask Condition=" '$(_ApiListingFile)' != '' "
20+
ApiListingPath="$(_ApiListingFile)"
21+
AssemblyPath="$(TargetPath)"
22+
Framework="$(TargetFramework)"
23+
ExcludePublicInternalTypes="$(ExcludePublicInternalTypes_InApiCheck)"
24+
ExclusionsPath="$(_ApiExclusionsFile)"
25+
ProjetAssetsPath="$(ProjectAssetsFile)" />
26+
27+
<Warning Condition=" '$(_ApiListingFile)' == '' "
28+
Text="No baseline file for $(TargetFramework) found in $(MSBuildProjectName)." />
29+
</Target>
30+
</Project>

src/Internal.AspNetCore.Sdk/build/Internal.AspNetCore.Sdk.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ for use outside of Microsoft.
44
-->
55
<Project>
66
<Import Project="$(MSBuildThisFileDirectory)..\targets\Common.targets" />
7+
<Import Project="$(MSBuildThisFileDirectory)ApiCheck.targets" />
78
<Import Project="$(MSBuildThisFileDirectory)GenerateAssemblyInfo.targets" />
89
<Import Project="$(MSBuildThisFileDirectory)Git.targets" />
910

0 commit comments

Comments
 (0)