简体   繁体   中英

Visual studio 2017 and nuget package

I am creating nuget package which should contain also config file. Problem is that if I want to use csproj for nuget package definition, I don't know how to specify that config file should be copied and "copy to output directory" on file set when package is being installed.

https://docs.microsoft.com/en-us/nuget/guides/create-net-standard-packages-vs2017

Previously I used nuspec and for install.ps1.

Thanks ( https://docs.microsoft.com/en-us/nuget/guides/create-net-standard-packages-vs2017 )

To include a file, you need to add / modify an update item for the file. If you have set "copy to output directory" to "preserve newest", you might already have one in the csproj file. To include this file into the resulting nuget package, you need to set the Pack="true" metadata:

<ItemGroup>
  <None Update="config.txt" CopyToOutputDirectory="PreserveNewest" Pack="true" />
</ItemGroup>

Note that depending on your project type (=> web sdk or "normal" sdk is being used) you may see different item types ( None , Content ) for files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM