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

Commit

Permalink
Add AspNetCore analyzers to Web.Sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavkm committed Mar 6, 2019
1 parent d847b04 commit de3dcf0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
11 changes: 10 additions & 1 deletion eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies></ProductDependencies>
<ProductDependencies>
<Dependency Name="Microsoft.AspNetCore.Mvc.Analyzers" Version="3.0.0-preview4-19154-11">
<Uri>https://github.com/aspnet/AspNetCore</Uri>
<Sha>0000</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.Mvc.Api.Analyzers" Version="3.0.0-preview4-19154-11">
<Uri>https://github.com/aspnet/AspNetCore</Uri>
<Sha>0000</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19154.14">
<Uri>https://github.com/dotnet/arcade</Uri>
Expand Down
16 changes: 16 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,25 @@
<RestoreSources>
$(RestoreSources);
https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/msbuild/api/v3/index.json;
https://www.myget.org/F/nugetbuild/api/v3/index.json;
https://dotnet.myget.org/F/dotnet-web/api/v3/index.json
</RestoreSources>
</PropertyGroup>

<!--
These versions should ONLY be updated by automation.
DO NOT UPDATE THESE MANUALLY. Use the `darc` command line tool to update this file so it stays in sync with
Version.Details.xml.
See https://github.com/dotnet/arcade/blob/master/Documentation/Darc.md for instructions on using darc.
-->
<PropertyGroup Label="Automated">
<MicrosoftAspNetCoreMvcAnalyzers>3.0.0-preview4-19154-11</MicrosoftAspNetCoreMvcAnalyzers>
<MicrosoftAspNetCoreMvcApiAnalyzers>3.0.0-preview4-19154-11</MicrosoftAspNetCoreMvcApiAnalyzers>
</PropertyGroup>
</Project>
24 changes: 23 additions & 1 deletion src/Web/Package/Microsoft.NET.Sdk.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,26 @@
<ProjectReference Include="$(RepoRoot)\src\Publish\Package\Microsoft.NET.Sdk.Publish.csproj" />
</ItemGroup>

</Project>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Analyzers" Version="$(MicrosoftAspNetCoreMvcAnalyzers)" PrivateAssets="All" BundleAsAnalyzer="true" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Api.Analyzers" Version="$(MicrosoftAspNetCoreMvcApiAnalyzers)" PrivateAssets="All" BundleAsAnalyzer="true" />
</ItemGroup>

<Target Name="_PackBundledAnalyzers" Inputs="@(PackageReference->HasMetadata('BundleAsAnalyzer'))" Outputs="%(PackageReference.Identity)" BeforeTargets="Build">
<PropertyGroup>
<_AnalyzerPath>$(NuGetPackageRoot)@(PackageReference->ToLower())\@(PackageReference->Metadata('Version')->ToLower())\analyzers\</_AnalyzerPath>
</PropertyGroup>
<ItemGroup>
<_AnalyzerFile Include="$(_AnalyzerPath)**\*.dll" />
</ItemGroup>

<Error
Text="No files found for analyzer for @(PackageReference) at path $(_AnalyzerPath)"
Condition="'@(_AnalyzerFile->Count())' == '0'" />

<ItemGroup>
<None Include="@(_AnalyzerFile)" Pack="true" PackagePath="analyzers/cs/%(_AnalyzerFile.Filename)%(_AnalyzerFile.Extension)" />
</ItemGroup>
</Target>

</Project>
4 changes: 4 additions & 0 deletions src/Web/Targets/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ Copyright (c) .NET Foundation. All rights reserved.
<ItemGroup Condition="'$(DisableImplicitFrameworkReferences)' != 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' >= '3.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" IsImplicitlyDefined="true" />
</ItemGroup>

<ItemGroup Condition="'$(DisableImplicitAspNetCoreAnalyzers)' != 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' >= '3.0'">
<Analyzer Include="$(MSBuildThisFileDirectory)..\analyzers\cs\*.dll" Condition="'$(Language)'=='C#'" IsImplicitlyDefined="true" />
</ItemGroup>

</Project>

0 comments on commit de3dcf0

Please sign in to comment.