Alias in ProjectReference does not work for framework-included packages
See original GitHub issueIssue moved from NuGet/Home#10438
- Please respond to @weltkante.
From @weltkante on Friday, January 8, 2021 4:19:41 PM
Details about Problem
In #4989 alias support for PackageReference was added, but when I try to create an alias to a framework-provided package this does not appear to work.
In particular, in a .NET 5 web application I add
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" Aliases="logging" />
but extern alias logging;
does not compile:
error CS0430: Der externe Alias "logging" wurde nicht in einer /reference-Option angegeben.
If I instead do it in a console application it indeed does work.
Using VS 2019 Update 9 Preview 2
Issue Analytics
- State:
- Created 3 years ago
- Comments:13
Top Results From Across the Web
How to `extern alias` an assembly with .Net core?
I had a problem in .Net Core 2.2 where the MySqlConnector type name and namespace had a collision and the answer was to...
Read more >PackageReference in project files - NuGet
Starting with NuGet 5.7 & Visual Studio 2019 Update 7, equivalent to ProjectReference, PackageReference supports Aliases . By default no aliases ...
Read more >How to use two types across assemblies with the same ...
If you are using Visual Studio, it is very easy to setup an extern alias. Just right click on the respective dependency within...
Read more >Unresolved references in error list to types in System.Web. ...
We reproduced the issue for projects that define an alias for a project reference. We are working on a fix.. Click to vote...
Read more >How to Use 'Extern Alias' to differentiate assemblies that use ...
In order to use extern aliases, you first need to open the .csproj file of your project and modify the PackageReference or ProjectReference...
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
This looks like a related issue. https://github.com/dotnet/msbuild/issues/4943
Problem Only the
extern alias
of the first occurrence of NuGet PackageReference is recognized v12. v11 results in compilation errorCS0430
Reproduce Steps
csproj
Program.cs (C# 11 / NET 7)
I even stumped ChatGPT with this one, it seemed so confident that it should be working and that I was doing something wrong.
Still busted, my project is net472.