Nuget Packager 项目的默认 XML 命名空间必须是 TFS 2017 中的 MSBuild XML 命名空间

Nuget Packager the default XML namespace of the project must be the MSBuild XML namespace in TFS 2017

我将要打包的项目类型从 .net Framework v4.6 更改为 .net standard 2.0,现在构建定义在 Nuget 打包程序步骤中失败,我收到此错误消息。

[error]The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.

研究此错误后,我了解到 NuGet 打包程序步骤不适用于基于 SDK 的 csproj 格式。

最好的替代方案是什么?我发现了同样的问题 ,但我在可用命令中找不到命令包。

虽然 pack 命令没有出现在下拉列表中,但您可以在字段中手动输入它。

我是这样解决这个问题的:

1- 将包元数据添加到 .csproj 文件。

2- 转到项目属性 -> 包并选中 "Generate NuGet package on build"。

3- 在构建定义中添加以下任务:

a- NuGet 恢复:

  • 设置解决方案的路径。

  • Select Feed 在我的 NuGet.config 作为 Feed 使用。

  • 设置路径为Nuget.config(通常项目根"src\nuget.config")。

b- Visual Studio 构建:

  • 设置解决方案的路径。

  • 平台:类似于 $(BuildPlatform).

  • 配置:类似于 $(BuildConfiguration).

c- 复制和发布构建工件:

  • 在内容中输入*.nupkg.
  • 设置复制根、工件名称和工件类型。