Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add analyzers to ref-pack / ASP.NET transport package #54950

Merged
merged 5 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/coding-guidelines/libraries-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ In some occasions we may want to include a library in the shared framework, but

Libraries included in the shared framework should ensure all direct and transitive assembly references are also included in the shared framework. This will be validated as part of the build and errors raised if any dependencies are unsatisfied.

Source generators and analyzers can be included in the shared framework by specifying `IsNetCoreAppAnalyzer`. These projects should specify `AnalyzerLanguage` as mentioned [below](#analyzers--source-generators).

Removing a library from the shared framework is a breaking change and should be avoided.

## Transport package
Expand All @@ -26,6 +28,8 @@ This package represents the set of libraries which are produced in dotnet/runtim

To add a library to the ASP.NETCore shared framework, that library should set the `IsAspNetCoreApp` property for its `ref` and `src` project. This is typically done in the library's `Directory.Build.props`, for example https://github.com/dotnet/runtime/blob/98ac23212e6017c615e7e855e676fc43c8e44cb8/src/libraries/Microsoft.Extensions.Logging.Abstractions/Directory.Build.props#L4.

Source generators and analyzers can be included in the ASP.NETCore shared framework by specifying `IsAspNetCoreAppAnalyzer`. These projects should specify `AnalyzerLanguage` as mentioned [below](#analyzers--source-generators).

Libraries included in this transport package should ensure all direct and transitive assembly references are also included in either the ASP.NETCore shared framework or the .NETCore shared framework. This is not validated in dotnet/runtime at the moment: https://github.com/dotnet/runtime/issues/52562

Removing a library from this transport package is a breaking change and should be avoided.
Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>36b148348ee8312f6369c0c56b0d0fe07deec603</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.SharedFramework.Sdk" Version="6.0.0-beta.21321.1">
<Dependency Name="Microsoft.DotNet.SharedFramework.Sdk" Version="6.0.0-beta.21329.8">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>36b148348ee8312f6369c0c56b0d0fe07deec603</Sha>
<Sha>6b9d24236d8d1906284e6cb6c28e3fe93a69b7d2</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201201-01">
<Uri>https://github.com/microsoft/vstest</Uri>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Microsoft.DotNet.PackageValidation": "1.0.0-preview.6.21274.7",
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21321.1",
"Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21321.1",
"Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.21321.1",
"Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.21329.8",
"Microsoft.Build.NoTargets": "3.0.4",
"Microsoft.Build.Traversal": "3.0.23",
"Microsoft.NET.Sdk.IL": "6.0.0-preview.7.21321.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<ItemGroup>
<ReferencePath Include="@(LibrariesRefAssemblies)" />
<DocFilesToPackage Include="$(ArtifactsBinDir)/docs/%(LibrariesRefAssemblies.FileName).xml" Condition="Exists('$(ArtifactsBinDir)/docs/%(LibrariesRefAssemblies.FileName).xml')"/>
<Analyzer Include="$(MicrosoftNetCoreAppRefPackDir)/analyzers/**/*.*" />
<FilesToPackage Include="@(Analyzer)" ExcludeFromValidation="true" TargetPath="analyzers/%(RecursiveDir)" />
</ItemGroup>
</Target>
</Project>
5 changes: 3 additions & 2 deletions src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@
<TestArchiveTestsDir>$(TestArchiveTestsRoot)$(OSPlatformConfig)/</TestArchiveTestsDir>
<TestArchiveRuntimeRoot>$(TestArchiveRoot)runtime/</TestArchiveRuntimeRoot>

<ASPNETCoreAppPackageRefPath>$(ArtifactsBinDir)pkg\aspnetcoreapp\ref</ASPNETCoreAppPackageRefPath>
<ASPNETCoreAppPackageRuntimePath>$(ArtifactsBinDir)pkg\aspnetcoreapp\lib</ASPNETCoreAppPackageRuntimePath>
<ASPNETCoreAppPackageRootPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'pkg', 'aspnetcoreapp'))</ASPNETCoreAppPackageRootPath>
<ASPNETCoreAppPackageRefPath>$([MSBuild]::NormalizeDirectory('$(ASPNETCoreAppPackageRootPath)', 'ref'))</ASPNETCoreAppPackageRefPath>
<ASPNETCoreAppPackageRuntimePath>$([MSBuild]::NormalizeDirectory('$(ASPNETCoreAppPackageRootPath)', 'lib'))</ASPNETCoreAppPackageRuntimePath>

<CommonPathRoot>$([MSBuild]::NormalizeDirectory('$(LibrariesProjectRoot)', 'Common'))</CommonPathRoot>
<CommonPath>$([MSBuild]::NormalizeDirectory('$(CommonPathRoot)', 'src'))</CommonPath>
Expand Down
7 changes: 7 additions & 0 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<IsNETCoreAppRef Condition="'$(IsNETCoreAppRef)' == '' and
'$(IsReferenceAssembly)' == 'true' and
$(NetCoreAppLibrary.Contains('$(AssemblyName);'))">true</IsNETCoreAppRef>

<!-- By default, disable implicit framework references for NetCoreAppCurrent libraries. -->
<DisableImplicitFrameworkReferences Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '$(NETCoreAppCurrentVersion)')) and
Expand All @@ -64,6 +65,8 @@

<BinPlaceRef Condition="'$(BinPlaceRef)' == '' and ('$(IsReferenceAssembly)' == 'true' or '$(IsRuntimeAndReferenceAssembly)' == 'true')">true</BinPlaceRef>
<BinPlaceRuntime Condition="'$(BinPlaceRuntime)' == '' and ('$(IsRuntimeAssembly)' == 'true' or '$(IsRuntimeAndReferenceAssembly)' == 'true')">true</BinPlaceRuntime>
<!-- remove when picking up https://github.com/dotnet/arcade/pull/7578 -->
<EnableBinplacing Condition="'$(IsAspNetCoreAppAnalyzer)' == 'true' or '$(IsNetCoreAppAnalyzer)' == 'true'">true</EnableBinplacing>
<BinPlaceForTargetVertical Condition="'$(BinPlaceForTargetVertical)' == ''">true</BinPlaceForTargetVertical>
<GetBinPlaceItemsDependsOn Condition="$(MSBuildProjectName.StartsWith('Microsoft.Extensions.'))">$(GetBinPlaceItemsDependsOn);AddDocumentationFileAsBinPlaceItemForExtensionsProjects</GetBinPlaceItemsDependsOn>
</PropertyGroup>
Expand Down Expand Up @@ -97,6 +100,10 @@
<RuntimePath>$(ASPNETCoreAppPackageRuntimePath)</RuntimePath>
<RefPath>$(ASPNETCoreAppPackageRefPath)</RefPath>
</BinPlaceTargetFrameworks>
<BinPlaceDir Include="$(ASPNETCoreAppPackageRootPath)\analyzers\dotnet\$(AnalyzerLanguage)"
Condition="'$(IsAspNetCoreAppAnalyzer)' == 'true'" />
<BinPlaceDir Include="$(MicrosoftNetCoreAppRefPackDir)analyzers\dotnet\$(AnalyzerLanguage)"
Condition="'$(IsNETCoreAppAnalyzer)' == 'true'" />

<!-- Setup the shared framework directory for testing -->
<BinPlaceTargetFrameworks Include="$(NetCoreAppCurrent)-$(TargetOS)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<UsingToolXliff>true</UsingToolXliff>
<CLSCompliant>false</CLSCompliant>
<IsPackable>false</IsPackable>
<IsAspNetCoreAppAnalyzer>true</IsAspNetCoreAppAnalyzer>
<AnalyzerLanguage>cs</AnalyzerLanguage>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<NoWarn>CS1574</NoWarn>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<UsingToolXliff>true</UsingToolXliff>
<IsNETCoreAppAnalyzer>true</IsNETCoreAppAnalyzer>
<AnalyzerLanguage>cs</AnalyzerLanguage>
</PropertyGroup>

<PropertyGroup>
Expand Down