SerilogAnalyzer icon indicating copy to clipboard operation
SerilogAnalyzer copied to clipboard

Analyser is installed as a project dependency and not a build dependency when installed from Nuget

Open JinsPeter opened this issue 3 years ago • 4 comments

image When installed SerilogAnalyzer, the package gets installed as a Project dependency rather than a build time dependency?

Below is a sample from a FxCopAnalyzer installation where the visual studio itself marked the package reference as <PrivateAssets> All </PrivateAssets>.

image

Is there anything to be done to install SerilogAnlyzer as a Build dependency. Is it okay if we manually mark it as a PrivateAssets=All?

JinsPeter avatar Mar 29 '22 11:03 JinsPeter

I don't think any of that is necessary, SerilogAnalyzer.dll is neither copied to the output directory nor are you able to access the SerilogAnalyzer namespace in your project where you are referencing the analyzer. Are there any other concerns i'm missing here? Marking it as PrivateAssets=All should be fine though, even though i don't see what that would change.

Suchiman avatar Mar 29 '22 11:03 Suchiman

My understanding is that if someone were to include this in their project and generate a nuget package from that this package would be listed as a dependency and it probably shouldn't be. That's why PrivateAssets should probably be included by default.

Banner-Keith avatar Nov 04 '22 00:11 Banner-Keith

Are there any other concerns i'm missing here?

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <TargetFramework>netstandard2.0</TargetFramework>
    <IsPackable>true</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
  </ItemGroup>

</Project>

From NugetPackageExplorer on dummy project built with SerilogAnalyzer: изображение

sungam3r avatar Nov 04 '22 14:11 sungam3r

@Suchiman Your package should be flagged as a developmentDependency. If it has that flag then Visual Studio should automatically create correct attributes in the <PackageReference> tag for your users to not include it as a dependency.

cremor avatar Aug 24 '23 09:08 cremor