【发布时间】:2020-08-15 17:26:55
【问题描述】:
我在 csproj 中使用下一个配置:
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<Reference Include="amqmdnet">
<HintPath>..\bin\amqmdnet.dll</HintPath>
</Reference>
<Content Include="..\bin\amqmdnet.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard2')) or $(TargetFramework.StartsWith('netcoreapp3'))">
<Reference Include="amqmdnetstd">
<HintPath>..\bin\amqmdnetstd.dll</HintPath>
</Reference>
<Content Include="..\bin\amqmdnetstd.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
</ItemGroup>
当项目使用具体框架设置时,它的每个部分都可以正常工作,例如:
<TargetFramework>netcoreapp3.1</TargetFramework>
但是当项目是多框架注意到发生时,dll不包括在内
<TargetFrameworks>netcoreapp3.1;net451</TargetFrameworks>
我在多框架场景中收到此消息,这是唯一的上下文:
我是如何进行的
由于某种原因nuget spec 没有填充元数据;我用 nuget 版本 5.5.1.6542 测试它。
- 我用VS建项目,怎么样。
- 将 {项目文件夹}\bin\Release\xxx.nupkg 的扩展名更改为 .zip
- 从 xxx.zip 中提取 xxx.nuspec 文件。它还将包含依赖项元数据。
- 使用NuGet Package Explorer 编辑xxx.nuspec
- 构建
nuget xxx.nuspec - .nuspec documentation
回答
我会把它贴在这里:
<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);GetMyPackageFiles</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<Target Name="GetMyPackageFiles">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<BuildOutputInPackage Include="amqmdnet.dll">
<FinalOutputPath>..\bin\amqmdnet.dll</FinalOutputPath>
</BuildOutputInPackage>
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard2')) or $(TargetFramework.StartsWith('netcoreapp3'))">
<BuildOutputInPackage Include="amqmdnetstd.dll">
<FinalOutputPath>..\bin\amqmdnetstd.dll</FinalOutputPath>
</BuildOutputInPackage>
</ItemGroup>
</Target>
【问题讨论】:
标签: visual-studio msbuild nuget visual-studio-2019