我为这个模糊的标题道歉,但我不知道如何措辞.
I apologize for the vague title, but I am not sure how to phrase it.
我正在使用自定义"appsettings.json 文件夹.json 文件位于使用它的类库中.我想创建一个 nuget 包来安装这个类库,但还要确保将 appsettings.json 复制到正确的目录中(如果我在控制台应用程序中安装它,则是构建输出目录).
I am working with a "custom" appsettings.json folder. The json file lives in the class library that is using it. I want to create a nuget package to install this class library but also make sure that appsettings.json is copied into the correct directory (if I am installing it in a console app, the build output directory).
我看到了一个答案"
如何我可以在我的 nuspec 文件中设置复制到输出目录"属性吗?
但我使用的是 VS 2019 和 .NET Standard 2.0.我很沮丧,因此感谢任何帮助(即使被告知不可能)!提前致谢.
but I am using VS 2019 and .NET Standard 2.0. I am pretty frustrated so any help (even if told not possible) is appreciated! Thanks in advance.
推荐答案如果你只想在 net core 项目上安装这个 nuget 包,你可以在 net 标准项目的 csproj 文件下添加这些节点:
If you just want to install this nuget package only on net core projects, you could just add these node under the net standard project's csproj file:
<ItemGroup> <None Update="xxx\appsettings.json" Pack="true" PackagePath="contentFiles\any\any;content"> <PackageCopyToOutput>true</PackageCopyToOutput> </None> </ItemGroup>然后,将net标准项目重新打包成nuget包,在新项目下安装之前,你应该首先清理 nuget 缓存.
Then, repack the net standard project into a nuget package, before install it under a new project, you should clean nuget caches first.
如果你想把这个nuget包安装到一个net framework项目中,你应该尝试使用net standard2.0 lib项目上的<package_id>.props文件.
If you want to install this nuget package into a net framework project, you should try to use <package_id>.props file on the net standard2.0 lib project.
请试试这个链接下的功能.
更多推荐
将 JSON 文件从类库 nuget 包复制到 bin
发布评论