4

我正在尝试VS Build tools 2017在 Jenkins 中构建一个 dotnet 3.5 项目解决方案文件。该项目使用 DotNet 3.5 的 MSBuild 编译得很好,但是当我使用MSBuild Engine Version 尝试相同的活动时15.9.21+g9802d43bc3,它正在抛出MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing.

这是我用来编译 dotnet 3.5 项目的命令。

cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
MSBuild.exe "%WORKSPACE%\WBR.sln" /p:Configuration=Debug /p:DeployOnBuild=True /p:AllowUntrustedCertificate=True /p:CreatePackageOnPublish=True

请在下面找到 Jenkins 执行日志

C:\Users\Netadmin\.jenkins\jobs\FCRS\jobs\FCRS_VS\workspace>cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" 

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin>MSBuild.exe "C:\Users\Netadmin\.jenkins\jobs\FCRS\jobs\FCRS_VS\workspace\WBR.sln" /p:Configuration=Debug /p:DeployOnBuild=True /p:AllowUntrustedCertificate=True /p:CreatePackageOnPublish=True 
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 8/19/2019 6:38:12 PM.
MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing.

Build FAILED.

  MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing.

    0 Warning(s)
    1 Error(s)

下图是我的詹金斯工作区目录。

任何帮助都会很棒。

在此处输入图像描述

4

1 回答 1

0

当您使用 commandmsbuild xx.sln时,您实际上是在构建属于该解决方案的项目。

根据您的错误消息:未加载项目的项目文件之一(xx.csproj)导致 msbuild 无法很好地读取 xml 内容。你可以试试:

1.打开 xx.csproj 文件并确保其格式为:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
</Project>

2.保存,UTF-8 encoding避免BOM被搞砸

3.备份然后删除.suo和.csproj.user文件

4.否则,由于是asp.net mvc项目,可以通过vs2017创建一个同名的asp.net mvc项目,将所有源文件复制到新项目中即可将项目迁移到VS2017

5.确保您的构建工具包安装了 Web 开发工作负载:

在此处输入图像描述

6.由于从.net3.5使用msbuild时效果很好,您可以在服务器中安装.net framework 3.5并尝试调用msbuild,C:\Windows\Microsoft.NET\Framework64\v3.5而不是C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin从vs2010构建.net 3.5项目时。

于 2019-08-21T06:02:01.930 回答