Sdk: Support extern aliases in DNX

Created on 18 Dec 2015  路  9Comments  路  Source: dotnet/sdk

_From @PinpointTownes on August 8, 2015 20:9_

image

Though not very popular, extern aliases are useful to work around CS0433 Type 'X' already exists in both 'A.dll' and 'B.dll' compilation errors, specially since we can't exclude transitive dependencies yet.

_Copied from original issue: aspnet/dnx#2445_

enhancement

Most helpful comment

+1

Any updates on this issue or if there is a way to accomplish the same with the current releases?

All 9 comments

+1
I'm quite surprised that it doesnt bother that much people...
For the record, I've asked about it on SO here

Yes this is quite surprising especially given the problems with the general bugginess of RC; sometimes I need to reference both old and new versions of the same library to hack it to work, but if the namespace hasn't changed I cannot because of the lack of alias support.

So +1 here

+1

Critical in RC enviroments

+1

Any updates on this issue or if there is a way to accomplish the same with the current releases?

It is very important to have options in case of multiple assemblies with the same namespaces.
2 libraries from CompanyA and CompanyB: both have Grid control in Controls namespace.
It is so obvious.... and it is easy to specify inside project.json

"dependencies": {
        "CompanyA.Library": { version: "2.0.0", alias: "LibraryA"}
    },
using GridA = LibraryA::Controls.Grid;

Seven months later and still nobody is assigned to fix this?

This problem just bit me too.

I found a hack that worked for me by (ab)using NuGet.Config and additionalArguments in project.json.

First, add a NuGet.Config with the following content:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value="../../packages" />
  </config>
</configuration>

Now, use buildOptions/additionalArguments in your project.json:

    "additionalArguments": [
      "/r:alias1=../../packages/Assembly1/1.0.0.0/lib/net45/Assembly1.dll",
      "/r:alias2=../../packages/Assembly2/1.0.0.0/lib/net45/Assembly2.dll",
      "/r:alias3=../../packages/Assembly3/1.0.0.0/lib/net45/Assembly3.dll"
    ],

This is a lousy hack, but it works as long as you explicitly specify the package version in the package dependency.

The team is actively working on enabling MSBuild and the component affected will be superseded by the new project system, so I am closing this issue.

Was this page helpful?
0 / 5 - 0 ratings