Azure devops 使用Azure管道从nuspec构建nuget文件
我遇到了一个奇怪的问题,几天来一直在努力解决。在本地,我可以使用以下nuspec文件构建我的项目。nuspec文件保存在repo中,从c#项目构建时复制到本地,它位于名为“nugetcreation”的子文件夹下。在本地,我可以按原样运行nuspec文件并生成nuget包 文件夹设置: 项目 -项目文件 -裸体创作 -自述文件和nuspec文件Azure devops 使用Azure管道从nuspec构建nuget文件,azure-devops,nuspec,Azure Devops,Nuspec,我遇到了一个奇怪的问题,几天来一直在努力解决。在本地,我可以使用以下nuspec文件构建我的项目。nuspec文件保存在repo中,从c#项目构建时复制到本地,它位于名为“nugetcreation”的子文件夹下。在本地,我可以按原样运行nuspec文件并生成nuget包 文件夹设置: 项目 -项目文件 -裸体创作 -自述文件和nuspec文件 <?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schem
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>my.Utility.TraceWriter</id>
<version>1.0.0-beta</version>
<title>my.Utility.TraceWriter</title>
<authors>justme</authors>
<owners>justme</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>custom trace items</description>
<releaseNotes>initial release</releaseNotes>
</metadata>
<files>
<file src="Content\MyReadMes\My.Utility.TraceWriter.md" target="content\net461\MyReadMes\My.Utility.TraceWriter.md" />
<file src="..\My.Utility.TraceWriter.dll" target="lib\net461\My.Utility.TraceWriter.dll" />
<file src="..\My.Utility.TraceWriter.pdb" target="lib\net461\My.Utility.TraceWriter.pdb" />
</files>
</package>
但它绝对是从vsbuild过程正确生成的
CopyFilesToOutputDirectory:
Copying file from "d:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\obj\Release\My.Utility.TraceWriter.dll" to "d:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\bin\Release\My.Utility.TraceWriter.dll"
azure管道中的nuget创建步骤非常基本,没有什么特别之处。我保存在nuspec文件中的所有花哨的东西。我正试图用nuspec文件在一个基本项目上实现这一点,因为我后面会有更复杂的nuget打包,所以这是我的测试版本
- task: NuGetCommand@2
displayName: 'Creating nuget package'
inputs:
command: 'pack'
packagesToPack: '**/*.nuspec'
versioningScheme: 'off'
arguments: '--configuration $(buildConfiguration)'
到目前为止,我已尝试使用:
- **\My.Utility.TraceWriter.dll(没有错误,但lib文件夹中没有dll。就像跳过了该行一样)
- bin**\My.Utility.TraceWriter.dll
- .\My.Utility.TraceWriter.dll
- $configuration$\My.Utility.TraceWriter.dll
- **\$configuration$\My.Utility.TraceWriter.dll
Added file '_rels/.rels'.
Added file 'My.Utility.TraceWriter.nuspec'.
Added file 'content/net461/MyReadMes/My.Utility.TraceWriter.md'.
Added file 'lib/net461/My.Utility.TraceWriter.dll'.
Added file 'lib/net461/My.Utility.TraceWriter.pdb'.
Added file 'package/services/metadata/core-properties/f2a4d059fea6458dac5889de57641f5b.psmdcp'.
Successfully created package 'D:\a\1\a\My.Utility.TraceWriter.1.0.0-beta.nupkg'.
WARNING: NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below:
- Add a dependency group for .NETFramework4.6.1 to the nuspec
Attempting to pack file: D:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\nuget information\My.Utility.TraceWriter.nuspec
C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe pack "D:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\nuget information\My.Utility.TraceWriter.nuspec" -NonInteractive -OutputDirectory D:\a\1\a -Properties Configuration=Release -Verbosity Detailed
Error NU5019: File not found: '..\My.Utility.TraceWriter.dll'.
NuGet Version: 5.4.0.6315
NuGet.Packaging.Core.PackagingException: File not found: '..\My.Utility.TraceWriter.dll'.
愚蠢的。packagesToPack:“***.nuspec”正在提取两个nuspec:源中的一个和复制到输出bin文件夹的一个
重新定义解决了这个问题太好了!谢谢你在这里分享你的解决方案,你可以,这样它可以帮助其他社区成员谁得到同样的问题,我们可以存档这个线程,谢谢。
Added file '_rels/.rels'.
Added file 'My.Utility.TraceWriter.nuspec'.
Added file 'content/net461/MyReadMes/My.Utility.TraceWriter.md'.
Added file 'lib/net461/My.Utility.TraceWriter.dll'.
Added file 'lib/net461/My.Utility.TraceWriter.pdb'.
Added file 'package/services/metadata/core-properties/f2a4d059fea6458dac5889de57641f5b.psmdcp'.
Successfully created package 'D:\a\1\a\My.Utility.TraceWriter.1.0.0-beta.nupkg'.
WARNING: NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below:
- Add a dependency group for .NETFramework4.6.1 to the nuspec
Attempting to pack file: D:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\nuget information\My.Utility.TraceWriter.nuspec
C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe pack "D:\a\1\s\My.Utility.TraceWriter\My.Utility.MethodTracer\nuget information\My.Utility.TraceWriter.nuspec" -NonInteractive -OutputDirectory D:\a\1\a -Properties Configuration=Release -Verbosity Detailed
Error NU5019: File not found: '..\My.Utility.TraceWriter.dll'.
NuGet Version: 5.4.0.6315
NuGet.Packaging.Core.PackagingException: File not found: '..\My.Utility.TraceWriter.dll'.