问题描述
朋友
我迷路了,我正在尝试为.net core 3.1应用打包一个nuget程序包,但我不断收到错误的程序包。
- Console1应用程序,.netcore3.1
- Console2应用程序,.netstandard2.0
Console1引用Console2。
我尝试为Console1创建一个nuget程序包,当我尝试将其安装在其他控制台上时,出现一个错误,提示Console2丢失并且找不到:
Severity Code Description Project File Line Suppression State
Error NU1101 Unable to find package ClassLibrary2. No packages exist with this id in source(s): Temp ConsoleApp7 C:\Users\xxx\source\repos\ConsoleApp7\ConsoleApp7\ConsoleApp7.csproj 1
然后,我将以下内容添加到项目文件中(在Google上阅读了一些内容):
<PropertyGroup> <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);copyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<Target Name="copyProjectReferencesToPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences">
<ItemGroup>
<!-- Filter out unnecessary files -->
<_ReferencecopyLocalPaths Include="@(ReferencecopyLocalPaths->WithMetadataValue('ReferenceSourceTarget','ProjectReference'))" />
</ItemGroup>
<!-- Print batches for debug purposes -->
<Message Text="Batch for .nupkg: ReferencecopyLocalPaths = @(_ReferencecopyLocalPaths),ReferencecopyLocalPaths.Destinationsubdirectory = %(_ReferencecopyLocalPaths.Destinationsubdirectory) Filename = %(_ReferencecopyLocalPaths.Filename) Extension = %(_ReferencecopyLocalPaths.Extension)" Condition="'@(_ReferencecopyLocalPaths)' != ''" />
<ItemGroup>
<!-- Add file to package with consideration of sub folder. If empty,the root folder is chosen. -->
<BuildOutputInPackage Include="@(_ReferencecopyLocalPaths)" TargetPath="%(_ReferencecopyLocalPaths.Destinationsubdirectory)" />
</ItemGroup>
</Target>
当我查看软件包时(使用软件包资源管理器),我现在看到nuget包含Console2的dll。但仍然-我遇到同样的错误。
我认为,如果dll存在,则依赖关系可能是一个问题,因此,我想也许我可以尝试看看是否可以以某种方式删除依赖关系,将PrivateAssets =“ all”添加到项目引用中,如下所示:
<ItemGroup>
<ProjectReference PrivateAssets="all" Include="..\ClassLibrary1\ClassLibrary1.csproj" />
</ItemGroup>
当我现在浏览该程序包时-我看到依存关系被移除了-仍然出现相同的错误。
这是什么,真的不可能为.netcoreapp3.1发布nuget软件包吗?
请帮助! 吉拉德
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)