最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - How to reference NuGet content files instead of copying with packages.config? - Stack Overflow

programmeradmin2浏览0评论

I create a nuget package for .Net 8 as well as with .Net Framework 4.7.2 containing .cs files only. When installing the package with old .Net project, NuGet copies the content into the project folder, and changes csproj file. Is it possible just to reference the files from the nuget cache like PackageReference does? Here's my nuspec file:

<?xml version="1.0"?> 
<package> 
  <metadata minClientVersion="3.3.0"> 
   <id>MyClient</id> 
   <version>1.0.0</version> 
   <authors>me</authors>
   <requireLicenseAcceptance>false</requireLicenseAcceptance> 
   <description>description</description> 
   <tags>myclient</tags> 
   <dependencies>
     <group targetFramework="net8.0">
        ...
     </group>
     <group targetFramework="net472">
       ...
     </group>
   </dependencies>
   <!-- Build actions for items in the contentFiles folder --> 
   <contentFiles>
      <files include="cs/**/*.*" buildAction="Compile" />
   </contentFiles> 
  </metadata> 
  <files> 
    <!-- this is for the new format -->
    <file src="myproject/MyClient.cs" target="contentFiles\cs\any\Client" />
    
    <!-- this is for the old format -->
    <file src="myproject/MyClient.cs" target="content\Client" />
  </files> 
</package>
发布评论

评论列表(0)

  1. 暂无评论