简体   繁体   English

Visual Studio 2017和nuget包

[英]Visual studio 2017 and nuget package

I am creating nuget package which should contain also config file. 我正在创建nuget包,其中还应包含配置文件。 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. 问题是,如果我要使用csproj定义nuget软件包,则在安装软件包时,我不知道如何指定应复制配置文件和在文件集上“复制到输出目录”。

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

Previously I used nuspec and for install.ps1. 以前,我使用nuspec和install.ps1。

Thanks ( https://docs.microsoft.com/en-us/nuget/guides/create-net-standard-packages-vs2017 ) 谢谢( https://docs.microsoft.com/zh-cn/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. 如果将“复制到输出目录”设置为“保留最新”,则csproj文件中可能已经有一个。 To include this file into the resulting nuget package, you need to set the Pack="true" metadata: 要将这个文件包含在生成的nuget包中,您需要设置Pack="true"元数据:

<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. 请注意,根据您的项目类型(正在使用=> web sdk或“正常” sdk),您可能会看到文件的不同项目类型( NoneContent )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Visual Studio 2017 RC中的.NET Core MSBuild项目创建NuGet包? - How do you create a NuGet package from a .NET Core MSBuild project in Visual Studio 2017 RC? 如何在Visual Studio 2017中生成非.NET Core库NuGet程序包 - How to generate a non-.NET Core Library NuGet package within Visual Studio 2017 如何在 Visual Studio 2017 为我创建的 NuGet 包中包含我的类库旁边的文本文件? - How do I include a text file alongside my class library in my NuGet package which Visual Studio 2017 is creating for me? 不使用Visual Studio构建类库(包)NuGet包项目 - Build Class Library (Package) NuGet Package Projects Without Visual Studio 如何设置Visual Studio来构建NuGet包? - How do I set Visual Studio to build a NuGet package? 使用Visual Studio Pack将构建目录包含在nuget包中 - Include build directory in nuget package using visual studio pack Visual Studio NuGet:为什么依赖包的.targets文件没有执行? - Visual Studio NuGet: Why dependent package's .targets file is not executed? 项目设置中缺少Visual Studio 2017包选项卡 - Visual Studio 2017 package tab is missing in project settings 如何更改 Visual Studio 项目中的 NuGet 包引用以使用 Nuget.config - How to change the NuGet-package reference in a Visual Studio project to use Nuget.config 在Visual Studio项目中使用“ nuget pack”时,覆盖nuget包名称 - Overriding nuget package name when using “nuget pack” with a visual studio project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM