-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to alias a package? #14
Comments
Why the issue was closed? Was it resolved? How? I have exactly the same question. |
@alex4998 did you figure this out? |
In .NET Core, use "same dll" with multiple version is allowed. because the dll files are no longer sit in bin folder together. It has been referenced as a package. The problem I referenced previously, it was caused by break changes of interface. Somehow, the referenced version hasn't been updated to reflect the changes. For example, we have referenced a package System.Security.Cryptography.Algorithms: "1.0.0.*", which means compatible all the packages 1.0.0.0 up, includes beta and alpha. If break changes has been introduced inside any of compatible version. And our system will try match and get the latest package on our system. Then it breaks. |
I understand that but it does not explain how to use aliases with referenced assemblies of the referenced package. Once again, my situation is this. I reference Google Drive API v2 package which has a lot of dependencies and one of those dependencies have exactly the same class name which results in a bunch of compiler errors because of the naming collision. Let’s say I have a namespace MyApplication.Library and there is class TaskEx. One of the package dependencies have a namespace System.Threading and there is TaskEx too. In some of my sources I have “using MyApplication.Library” and “using System.Threading” (with this using I didn’t refer to the package dependency assembly, I referred to the system System.Threading but it happened to have the same namespace). In these conditions I’m getting the naming collision errors from the compiler everywhere I’m using TaskEx. With the NuGet v2.* the situation can be easily resolved changing dependent assembly aliases from ‘global’ to let’s say ‘google’ and everything compiles after that. With the NuGet v3.0 I don’t know how to change dependency assembly aliases to fix my problem. So, I’m looking for a workaround and hope on a resolution of this lack of functionality in the future versions. Thank you, Alex From: Yue Zhou [mailto:[email protected]] In .NET Core, use "same dll" with multiple version is allowed. because the dll files are no longer sit in bin folder together. It has been referenced as a package. The problem I referenced previously, it was caused by break changes of interface. Somehow, the referenced version hasn't been updated to reflect the changes. For example, we have referenced a package System.Security.Cryptography.Algorithms: "1.0.0.*", which means compatible all the packages 1.0.0.0 up, includes beta and alpha. If break changes has been introduced inside any of compatible version. And our system will try match and get the latest package on our system. Then it breaks. — This email has been checked for viruses by Avast antivirus software. |
You always can use "using" to alias a namespace. In our source code, on the top using statements section, add "using my = MyApplication.Library", then you can use "my.TaskEx" just like how .NET works before. |
Right. It works as a workaround but ideally, of course, I’d like to be able to change aliases on the dependency assemblies. Simply because in this case I don’t need to change a single line in the code. With using aliases I at least need to change all the usings and change the lines referring those usings. Thanks anyway, Alex From: Yue Zhou [mailto:[email protected]] You always can use "using" to alias a namespace. In our source code, on the top using statements section, add "using my = MyApplication.Library", then you can use "my.TaskEx" just like how .NET works before. — This email has been checked for viruses by Avast antivirus software. |
In my case the type's fullname is duplicated in two assemblies. And I can't use extern to differentiate. |
I think this issue should be open, too. I referenced |
This should probably be opened in the Nuget/Home repo. |
There's a NuGet issue already with the current "workaround" being to write a custom target like |
thanks @dasMulli EDIT: that doesn't work on F# :( no |
What a perfect support of doing nothing! Still no reaction to the pain of developers? |
@dshalin the issue was closed by the person who created it. We do not comment or reply to comments on closed issues. |
Previously, when we have a same namespace class sits in different dll files we can use extern alias to distinguish them.
I don't know how to deal with nuget package in project.json file.
An example will be
Severity Code Description Project File Line
Error CS0433 The type 'HMACSHA1' exists in both 'System.Security.Cryptography.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Security.Cryptography.Hashing.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Hema.Auth.Identity.DNX Core 5.0
The text was updated successfully, but these errors were encountered: