Open natemcmaster opened 7 years ago
Ping @nguerrera. Still happening in 2.0.0-preview3-006609
cc @rrelyea
cc @mikeharder
This issue also occurs when a project includes a package that excludes analyzes from it's .nuspec. The solution ends up including the nested dependency analyzers and I get IDE1002 errors during the build.
Blocked by https://github.com/NuGet/Home/issues/6279
I'm encountering this in a conversion to the new SDK style projects. The change in behavior of transitive dependencies means that a single package with an analyzer is now breaking our builds as that analyzer is enforcing itself virally. When coupled with warn as error, this is a difficult problem to work around.
Still blocked by NuGet/Home#6279
I'm curious about what's going on with this. Right now I'm building analyzers and generators for our company and even when I exclude them they throw an error because the project that is consuming them isn't configured to use the analyzers
@EdLichtman you can sort of work around it by using buildTransitive
MSBuild targets that provide the "configuration" your analyzers need.
That is indeed a workaround but it hides the dependency from the target who references it. It's an example of a side effect and a very bad side effect because what if the analyzer it downloads needs to go through legal? In my case I'm writing the analyzer but I'm curious what is the status on when this will be fixed?
Also btw, @kzu I was wondering what best practices for adding buildTransitive are...
Let's say I have a library: My.Library Now, I have:
When I have both of those, only the buildTransitive seems to get referenced. Therefore what I've resorted to doing is:
Adding the following to buildTransitive:
Is there a better way of doing it?
If analyzers need anything from MSBuild, you must use buildTransitive. And from there you can import a non-transitive shared targets, if needed.
I really need a fix for this. refit is breaking my code because of this https://github.com/reactiveui/refit/discussions/1764
NuGet provides the "ExcludeAssets" setting to allow excluding analyzers from packages. However, it appears the SDK still includes analyzers in the build even if excluded.
(cref https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#controlling-dependency-assets)
Repro
Expected The analyzer in
xunit.analzyers/0.1.0/analyzers/dotnet/cs/xunit.analyzers.dll
should not have been passed to CSC, and build succeeds.Result
Details Using dotnet.exe 2.0.0-preview2-006067
project.assets.json file contains: