在过去的几天里,我尝试通过TFS为特定项目部署持续交付,这让我感到非常沮丧。该项目是一个内部库,必须在私有NuGet仓库上发布,因此其中一个步骤是打包nupkg文件。
我现在遇到的问题是nuget pack
抱怨在某些情况下遗失Authors
和Description
,而在其他情况下则没有。{1}}我的AssemblyInfo.cs对于它失败的最简单的项目就像它们来的那样:
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("A.B.C")]
[assembly: AssemblyDescription("Some description here")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Company // Department")]
[assembly: AssemblyProduct("A.B.C")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("88888888-8888-8888-8888-888888888888")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
我清理了这些值,但我保留了我使用的实际值的格式(例如,而不是" ABC"我们有" LibraryName.Module.Submodule" )。
nuspec文件同样无聊:
<?xml version="1.0"?>
<package >
<metadata>
<!-- Mandatory, static stuff -->
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<description>$description$</description>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<!-- Mandatory stuff you should review upon re-packaging -->
<releaseNotes>The first internal release.</releaseNotes>
<copyright>Copyright 2018</copyright>
<!-- Optional stuff you should only include if you need it -->
<projectUrl>http://www.example.com/</projectUrl>
<!-- <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl> -->
<!-- <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl> -->
<!-- <tags>Tag1 Tag2</tags> -->
</metadata>
</package>
运行nuget pack
时,有时会因臭名昭着而失败&#34; 需要作者;需要说明 &#34;。我随机取得了成功,摆弄了不应影响流程的事情,例如添加或删除依赖项,或者在文件系统周围移动nuget二进制文件。是的,我确实检查过,在所有实验中,在二进制路径的任何地方都没有nuget.config
个文件 - 但是,在一些非常精心设计的设置中它仍然有用,而在其他实验中它并没有。
我目前在代理池中有两台服务器;在其中一个上它与nuget 4.6.2一起使用,并且它不适用于4.7.0。另一方面,它既不适用。当我点击它工作的设置时,它每次运行构建时都会一致地工作 - 但是现在我有一个工作的服务器和一个不工作的服务器,我完全不知道为什么会发生这种情况(并且它们在构建中都是一致的)。
我发现了一个错误报告token replacement fails我遇到的错误,原因与AssemblyInfo.cs的格式有关,但我不认为这是因为我的项目 - 然后再次,我学会期待任何事情。
这里是完整的执行日志:
C:\Program Files\nuget.4.6.2.exe pack "C:\TFS-Agent\_work\2\s\A.B.C\A.B.C.csproj" -OutputDirectory "C:\TFS-Agent\_work\2\s\publish" -Properties Configuration=release -Verbosity detailed
NuGet Version: 4.6.2.5055
Attempting to build package from 'A.B.C.csproj'.
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Packing files from 'C:\TFS-Agent\_work\2\s\A.B.C\bin\Release'.
Using 'A.B.C.nuspec' for metadata.
Authors is required.
Description is required.
System.Exception: Authors is required.
Description is required.
at NuGet.Packaging.Manifest.Validate(Manifest manifest)
at NuGet.Packaging.Manifest.ReadFrom(Stream stream, Func`2 propertyProvider, Boolean validateSchema)
at NuGet.CommandLine.ProjectFactory.ProcessNuspec(PackageBuilder builder, String basePath)
at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded, PackageBuilder builder)
at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
at NuGet.Commands.PackCommandRunner.BuildPackage()
at NuGet.CommandLine.PackCommand.ExecuteCommand()
at NuGet.CommandLine.Command.ExecuteCommandAsync()
at NuGet.CommandLine.Command.Execute()
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
System.Exception: Unexpected exit code 1 returned from tool nuget.4.6.2.exe
at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
直到错误的输出在其工作的服务器上是相同的(即直到并包括Using 'A.B.C.nuspec' for metadata.
)。唯一的区别是......嗯......它有效。
如果您能提出任何我可以进一步调查的指示,请与我们联系。
答案 0 :(得分:0)
我有类似的问题。我必须在csproj中包含Description元素并设置为一个值。该文档很有帮助。 https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets
答案 1 :(得分:0)
我们在Azure Devops中有一个构建定义,该定义具有自定义的powershell构建步骤,该步骤在基于构建定义中的变量进行构建之前修改了AssemblyInfo.cs文件。我们使用它来将软件包的版本标签为Alpha,Beta等。
我遇到了同样的错误,只需要在对构建进行排队时就不必在该变量中添加下划线。