Skip to content

Including native libraries in dotnet projects without nuget package #7017

Closed

Description

@nicolasr75

According to the current documentation the packOptions would allow us to specify a native library for inclusion in a nuget package. Wouldn't it be great if we could have something similar for a normal app publish? That would allow us to bypass the creation of a nuget package for simple scenarios.

For example:

"packOptions":{
    "files":{
        "mappings":{
            "runtimes/win10-x64/native":{
                "includeFiles":[ "native-lib.dll"]
            }
        }            
    }
}

From my tests it looks like packOptions is not considered by dotnet publish.

https://docs.microsoft.com/de-de/dotnet/articles/core/tutorials/libraries

Activity

  1. thesmithee commented on Jan 13, 2017

    @thesmithee

    MSBuild allows this very easily using the <Content> element. Is this what is looked for here?

  2. tmds commented on Jan 13, 2017

    @tmds
    Member

    From my tests it looks like packOptions is not considered by dotnet publish.

    @nicolasr75 try using publishOptions (see https://docs.microsoft.com/en-us/dotnet/articles/core/tools/project-json)

  3. nicolasr75 commented on Jan 15, 2017

    @nicolasr75
    Author

    @tmds thanks, indeed it seems to be as easy as

    "publishOptions": {
        "include": [
    		"My.dll"
    	]
    }
    

    I somehow thought I'd have to create all the runtime directories dynamically and copy the DLL to all of them. In my case the DLL is the same for all runtimes and it works by simply copying it to the publish base directory.

  4. nicolasr75 commented on Jan 15, 2017

    @nicolasr75
    Author

    @BlackDwarf yes, I guess <Content> may work. I will try it as soon as I port the project to VS2017.

  5. thesmithee commented on Jan 20, 2017

    @thesmithee

    @nicolasr75 I will assume that this worked since MSbuild's <Content> is tried and true so will therefore close this issue. :) If you run into problems or it doesn't work, please reopen.

  6. transferred this issue fromdotnet/clion Jan 31, 2020
  7. added this to the 1.0.0-rtm milestone on Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions