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

I create a nuget package for .Net 8 as well as with .Net Framework 4.7.2 containing .cs files only. Whe

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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745609335a4635855.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信