【发布时间】:2017-03-01 00:34:11
【问题描述】:
我正在尝试通过 VS2017 创建自定义包,但到目前为止没有成功。我正在尝试将一些 .txt 文件添加到包的根目录,但它不起作用。
解决方案的结构:
ClassLibrary1.csproj
---> NugetContentFolder/Example1.txt
所需结构(Nuget):
ClassLibray1.dll
Example1.txt
我试试:
构建 -> 打包 ClassLibrary1
XML:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net45</TargetFrameworks>
<Authors>A</Authors>
<Company>B</Company>
<Product>C</Product>
<Copyright>E</Copyright>
<PackageLicenseUrl>F</PackageLicenseUrl>
<PackageProjectUrl>G</PackageProjectUrl>
<PackageIconUrl>H</PackageIconUrl>
<RepositoryUrl>I</RepositoryUrl>
<RepositoryType>J</RepositoryType>
<PackageTags>L</PackageTags>
<PackageReleaseNotes>M</PackageReleaseNotes>
<NeutralLanguage>en-US</NeutralLanguage>
<Description>H</Description>
<files>
<file src="Folder1/Example1.txt" target="Example1.txt" />
</files>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PackageReference Include="Newtonsoft.Json" Version="9.0.2-beta2" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.0.1-beta-003206" />
<PackageReference Include="System.Runtime.Loader" Version="4.0.0" />
<PackageReference Include="System.Reflection.Extensions" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNet.Razor" Version="3.0.0" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
我该怎么做?
最后,我发现将这些信息耦合到“csproj”中非常糟糕,在我看来,分离到另一个文件中并不困难。
【问题讨论】:
-
您找到解决方案了吗?
-
不,我改变了我的 nuget 包
-
这个链接可能有用:docs.microsoft.com/en-us/nuget/reference/msbuild-targets 它包含一些解决问题的方法,但我没有测试它们。
标签: customization nuget-package pack visual-studio-2017