Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit de3dcf0

Browse files
committed
Add AspNetCore analyzers to Web.Sdk
Fixes dotnet/aspnetcore#4373
1 parent d847b04 commit de3dcf0

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

eng/Version.Details.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
3-
<ProductDependencies></ProductDependencies>
3+
<ProductDependencies>
4+
<Dependency Name="Microsoft.AspNetCore.Mvc.Analyzers" Version="3.0.0-preview4-19154-11">
5+
<Uri>https://github.com/aspnet/AspNetCore</Uri>
6+
<Sha>0000</Sha>
7+
</Dependency>
8+
<Dependency Name="Microsoft.AspNetCore.Mvc.Api.Analyzers" Version="3.0.0-preview4-19154-11">
9+
<Uri>https://github.com/aspnet/AspNetCore</Uri>
10+
<Sha>0000</Sha>
11+
</Dependency>
12+
</ProductDependencies>
413
<ToolsetDependencies>
514
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19154.14">
615
<Uri>https://github.com/dotnet/arcade</Uri>

eng/Versions.props

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@
1313
<RestoreSources>
1414
$(RestoreSources);
1515
https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
16+
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
1617
https://dotnet.myget.org/F/msbuild/api/v3/index.json;
1718
https://www.myget.org/F/nugetbuild/api/v3/index.json;
1819
https://dotnet.myget.org/F/dotnet-web/api/v3/index.json
1920
</RestoreSources>
2021
</PropertyGroup>
22+
23+
<!--
24+
25+
These versions should ONLY be updated by automation.
26+
27+
DO NOT UPDATE THESE MANUALLY. Use the `darc` command line tool to update this file so it stays in sync with
28+
Version.Details.xml.
29+
30+
See https://github.com/dotnet/arcade/blob/master/Documentation/Darc.md for instructions on using darc.
31+
32+
-->
33+
<PropertyGroup Label="Automated">
34+
<MicrosoftAspNetCoreMvcAnalyzers>3.0.0-preview4-19154-11</MicrosoftAspNetCoreMvcAnalyzers>
35+
<MicrosoftAspNetCoreMvcApiAnalyzers>3.0.0-preview4-19154-11</MicrosoftAspNetCoreMvcApiAnalyzers>
36+
</PropertyGroup>
2137
</Project>

src/Web/Package/Microsoft.NET.Sdk.Web.csproj

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,26 @@
2828
<ProjectReference Include="$(RepoRoot)\src\Publish\Package\Microsoft.NET.Sdk.Publish.csproj" />
2929
</ItemGroup>
3030

31-
</Project>
31+
<ItemGroup>
32+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Analyzers" Version="$(MicrosoftAspNetCoreMvcAnalyzers)" PrivateAssets="All" BundleAsAnalyzer="true" />
33+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Api.Analyzers" Version="$(MicrosoftAspNetCoreMvcApiAnalyzers)" PrivateAssets="All" BundleAsAnalyzer="true" />
34+
</ItemGroup>
35+
36+
<Target Name="_PackBundledAnalyzers" Inputs="@(PackageReference->HasMetadata('BundleAsAnalyzer'))" Outputs="%(PackageReference.Identity)" BeforeTargets="Build">
37+
<PropertyGroup>
38+
<_AnalyzerPath>$(NuGetPackageRoot)@(PackageReference->ToLower())\@(PackageReference->Metadata('Version')->ToLower())\analyzers\</_AnalyzerPath>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<_AnalyzerFile Include="$(_AnalyzerPath)**\*.dll" />
42+
</ItemGroup>
43+
44+
<Error
45+
Text="No files found for analyzer for @(PackageReference) at path $(_AnalyzerPath)"
46+
Condition="'@(_AnalyzerFile->Count())' == '0'" />
47+
48+
<ItemGroup>
49+
<None Include="@(_AnalyzerFile)" Pack="true" PackagePath="analyzers/cs/%(_AnalyzerFile.Filename)%(_AnalyzerFile.Extension)" />
50+
</ItemGroup>
51+
</Target>
52+
53+
</Project>

src/Web/Targets/Sdk.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@ Copyright (c) .NET Foundation. All rights reserved.
3333
<ItemGroup Condition="'$(DisableImplicitFrameworkReferences)' != 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' >= '3.0'">
3434
<FrameworkReference Include="Microsoft.AspNetCore.App" IsImplicitlyDefined="true" />
3535
</ItemGroup>
36+
37+
<ItemGroup Condition="'$(DisableImplicitAspNetCoreAnalyzers)' != 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' >= '3.0'">
38+
<Analyzer Include="$(MSBuildThisFileDirectory)..\analyzers\cs\*.dll" Condition="'$(Language)'=='C#'" IsImplicitlyDefined="true" />
39+
</ItemGroup>
3640

3741
</Project>

0 commit comments

Comments
 (0)