dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.

Home Page:https://docs.microsoft.com/visualstudio/msbuild/msbuild

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[On Hold] Prepary Microsoft.Build.Analyzers.AuthoringContracts assembly

JanKrivanek opened this issue · comments

Context

In order to author custom analyzer, one would need to reference Microsoft.Build currently. That is however carrying over too much other public API, so it can get confusing.
Extracting the analyzers contracts to separate assembly has it's own perf and usability concerns (e.g. #9735 (comment)) - so the code is currently part of Microsoft.Build.
But we can prepare a spearate assembly - Microsoft.Build.Analyzers.AuthoringContracts - that just links all the contract codefiles used in Microsoft.Build, so that users can have a lightweight assembly to reference

Gotchas

Such an assembly wouldn't be possible to use at runtime together with Microsoft.Build - due to duplicite existence of types. Users would need to be guided to reference it as compile time only reference (private assets). But we should think about putting some safety check that fails fast and more clearly in such situation (e.g. assembly initialization code that checks for presence of other msbuild assemblies?)

Users would need to be guided to reference it as compile time only reference (private assets).

NuGet supports developmentDependency in nuspec for this purpose.

Or perhaps you can set up a package with a reference assembly that has type definitions, but a runtime assembly that is built with TypeForwardedToAttribute, similar to the netstandard assemblies.