How to share source code via NuGet packages for use in .NET Core projects

后端 未结 1 447
说谎
说谎 2020-12-18 05:07

I want to make small pieces of source code (e.g. helper classes) available for use in .NET Core projects (.csproj). At this point I packaged the source code with NuGet in ma

1条回答
  •  失恋的感觉
    2020-12-18 05:37

    Is it meant to be possible at all? If so, how should it be done?

    The answer is yes. Since you test project type is .net core. You should use contentFiles instead of content. content is used for packages.config. Check the Using the contentFiles element for content files and blog NuGet ContentFiles Demystified for more details.

    So your .nuspec file should be:

    
    
      
        MyTestCore
        5.0.0
        TestContentFile
        TestContentFile
        false
        Package Description
        
          
        
      
    
      
        
      
    
    

    The nuget package should be looks like:

    Note: When you create a new package, do not forgot to remove the nuget cache for this package in the C:\Users\\.nuget\packages folder, otherwise, it always install the old package.

    With this method, the source files will be included into your project.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题