Pack when referencing Microsoft.CodeAnalysis.CSharp generates exclude="Build,Analyzers"
See original GitHub issueRepro steps:
- New project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Version>0.1.0-dev</Version>
<Authors>Author</Authors>
<Description>Descriptor</Description>
<NeutralLanguage>en</NeutralLanguage>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.3.1" />
</ItemGroup>
</Project>
- Build in VS
- Check created package.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>PackRepro</id>
<version>0.1.0-dev</version>
<authors>Author</authors>
<owners>Author</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<description>Descriptor</description>
<dependencies>
<group targetFramework=".NETStandard1.3">
<dependency id="Microsoft.CodeAnalysis.CSharp" version="2.3.1" exclude="Build,Analyzers" />
<dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
</package>
I tried <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.3.1" PrivateAssets="none"/>
but it did not have any effect.
Is there a way to pack this so that analyzers are not excluded? Is there documentation about this?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:28 (8 by maintainers)
Top Results From Across the Web
SourceGenerator analyzer package works in Visual Studio ...
So far I've: Cleared the nuget cache; deleted the .vs folder; restarted VS 2019. And no luck. Any help is appreciated. c# ......
Read more >PackageReference in project files - NuGet
Package references, using <PackageReference> MSBuild items, specify NuGet package dependencies directly within project files, as opposed to ...
Read more >Code analysis in .NET
NET compiler platform (Roslyn) analyzers inspect your C# or Visual Basic code for code quality and style issues. Starting in .NET 5, these ......
Read more >CSharpCompilation.WithReferences Method
Creates a new compilation with the specified references.
Read more >CSharpCompilation Class (Microsoft.CodeAnalysis.CSharp)
A compilation can produce a new compilation from existing compilation with the application of small deltas. In many cases, it is more efficient...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The exact repro didn’t matter in my case:
Here’s the generated nuspec.
I’ll do some digging to see if I can figure out the scenario in which it ends up not working.
It’d be helpful if you can provide us the assets file right before you pack.
Pack burns in the restored versions of packages, not the requested ones. So it’s by design right now.
Pack also doesn’t run build if it’s out of date. I see restore as the same thing.
Note that even if pack were to do an up to date restore check, it’d then need to run an up to date build check.
I’m not saying it’ll never ever change or something like that, I just don’t see any immediate changes happening 😃