Using Microsoft.Build component to load a csproj using method ProjectCollection.GlobalProjectCollection.LoadProject. Documentation here.
Loading a csproj with PackageReference and ExcludeAsset attribute in one of the references, example:
<PackageReference Include="SomePackage" ExcludeAssets="Compile">
<Version>1.0.0</Version>
</PackageReference>
The following exception is thrown:
The attribute "ExcludeAssets" in element is unrecognized.
Already tried different ToolVersions (2.0 | 4.0 |12.0), and both of the projects are compiled in .net472
How can I fix this?
Thanks
I found a solution that is related to @AluanHaddad response. The project that is calling ProjectCollection.GlobalProjectCollection.LoadProject. if it uses the new SDK style, is able to load an older csproj with packagereferences and ExcludeAssets attribute.