sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Asp.net core referencing an assembly on a mac

Open casamm opened this issue 9 years ago • 4 comments

I've been trying to link to a dll while running asp.net core app on my Mac. Earlier I came through some threads on the same rep which were mentioning that asp.net core is p2p etc. but then I found project.json reference that has an entry for specifying dll's.

"frameworks": {
    "netcoreapp1.0": {
        "bin": {
            "assembly": "c:/otherProject/otherdll.dll"
        }
    }
}

Steps to reproduce

Since I'm on the mac I updated to the following.

"assembly": "/Users/myname/Documents/TestProject/libs/MyLib.dll"

Expected behavior

I should be able to not only link the dll but to be able to see code hinting/Intellisense in my Visual Studio Code for mac.

Also if possible is there a way to specify relative paths to the project instead of absolute path to the DLLs?

Actual behavior

Instead I get an error

/Users/myname/Documents/TestProject/Startup.cs(10,7): 
error CS0246: The type or namespace name 'MyLib' could not be found (are you missing a using directive or an assembly reference?)

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information: Version: 1.0.0-preview2-1-003177 Commit SHA-1 hash: a2df9c2576

Runtime Environment: OS Name: Mac OS X OS Version: 10.12 OS Platform: Darwin RID: osx.10.12-x64

casamm avatar Feb 16 '17 15:02 casamm

@casamm We are no longer actively developing support for the project.json format, as we have moved to MSBuild since preview3.

I am not sure what kind of support to project.json VS for MAC has either.

We do support to individual assemblies in MSBuild, however, for 1.0, we support that only for full framework (net4x) and not for dotnet core. We do have a PR out that will support for it in 2.0, but that is not even preview yet and is very early work.

In the mean time, even though this does not work in VS for MAC, have you tried restoring and building through the command line?

livarcocc avatar Feb 16 '17 17:02 livarcocc

dotnet restore didn't work. I copied source files for the dll to my project for the time being to work it out, I look forward to .net core support. Also enlighten me please on the MSBuild workflow/template.

casamm avatar Feb 20 '17 17:02 casamm

We have release 1.0.1 of the CLI a couple of weeks ago.

We have a dotnet migrate command on the CLI that converts your project.json projects to csproj. Also, the latest preview of VS for MAC supports this new csproj format. Though, it is in preview for them.

livarcocc avatar Mar 16 '17 20:03 livarcocc

good news, i like the way where it's heading. Utilizing csproj instead of project.json is much better since it's cross platform. I've few questions

  1. how do I link a Portable Class Library or .netcore dll with my project? (I'm on a mac)

  2. Can you create a custom dll based library project (.netcore or PCL) on the mac?

  3. Is there a nuget integration or how can we pull code from nuget?

  4. Can it handle solution file (.sln) if I've a multi-modular project app?

casamm avatar Mar 19 '17 21:03 casamm