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

NuGet Pack Target should have a switch for creating analyzers #6793

Open
tannergooding opened this issue Apr 9, 2018 · 2 comments
Open

NuGet Pack Target should have a switch for creating analyzers #6793

tannergooding opened this issue Apr 9, 2018 · 2 comments

Comments

@tannergooding
Copy link

tannergooding commented Apr 9, 2018

Today, the NuGet.Build.Tasks.Pack.targets only supports creating tools (via the IsTool property) and lib (the default) packages.

The targets should be updated to additionally support an IsAnalyzer property which defaults the various values to support the creation of .NET Analyzers (https://docs.microsoft.com/en-us/nuget/reference/analyzers-conventions).

Ideally, there would be additional properties to also control things like the supported framework (currently dotnet is the only supported), supported architecture, and supported languages.

The current workaround is to manually set BuildOutputTargetFolder to analyzers/{framework_name}{version}/{supported_architecture}/{supported_language} where {framework_name}{version}, {supported_architecture} and {supported_language} are optional.

@mishra14
Copy link
Contributor

mishra14 commented Apr 9, 2018

pinging @rohit21agrawal for visibility

@mishra14 mishra14 added Functionality:Pack Type:DCR Design Change Request labels Apr 9, 2018
@mishra14 mishra14 added this to the Backlog milestone Apr 9, 2018
@rohit21agrawal rohit21agrawal added Type:Feature and removed Type:DCR Design Change Request labels Apr 9, 2018
@nkolev92 nkolev92 added Style:PackageReference Priority:2 Issues for the current backlog. and removed Triage:Investigate labels Nov 30, 2018
@jnm2
Copy link

jnm2 commented Jul 19, 2019

The current workaround is to manually set BuildOutputTargetFolder to analyzers/{framework_name}{version}/{supported_architecture}/{supported_language} where {framework_name}{version}, {supported_architecture} and {supported_language} are optional.

Unfortunately BuildOutputTargetFolder is no help since the analyzer's target framework is appended to that path, and e.g. analyzers/dotnet/cs/netstandard1.3 is not a valid path according to https://docs.microsoft.com/en-us/nuget/reference/analyzers-conventions#analyzers-path-format.

@rohit21agrawal posted one workaround at #6184 (comment):

  <PropertyGroup>
    <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);GetMyPackageFiles</TargetsForTfmSpecificBuildOutput>
  </PropertyGroup>

  <Target Name="GetMyPackageFiles">
    <ItemGroup>
      <TfmSpecificPackageFile Include="$(OutputPath)$(AssemblyName).dll">
        <PackagePath>analyzers/dotnet/cs</PackagePath>
      </TfmSpecificPackageFile>
    </ItemGroup>
  </Target>

The .NET Compiler Platform SDK has a different approach in its analyzer project template:
https://github.com/dotnet/roslyn-sdk/blob/master/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj

  <PropertyGroup>
    <IncludeBuildOutput>false</IncludeBuildOutput>
  </PropertyGroup>

  <ItemGroup>
    <None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
  </ItemGroup>

The analyzer projects I've seen on GitHub so far tonight seem to have gone with managing the nuspec manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants