DNX 构建失败 - 从 msbuild.exe 收到意外退出代码:1

DNX Build Failed - Unexpected exit code received from msbuild.exe: 1

我不明白为什么下面的构建失败了。

项目构建成功。

“##[error]从 msbuild.exe 接收到意外退出代码:1”会导致以下输出结果吗?

 Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\tasks\VSBuild.0.13\VSBuild.ps1
 C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe "C:\aac4a4f6\Root\src\MyProject.Api\MyProject.Api.xproj" /nologo /m /nr:false /fl /flp:"logfile=C:\aac4a4f6\Root\src\MyProject.Api\MyProject.Api.xproj.log" /dl:CentralLogger,"C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /t:Build,FileSystemPublish /p:PublishConfiguration=release /p:PublishOutputPathNoTrailingSlash=C:\aac4a4f6\Root\MyProject\artifacts\bin\release\Publish /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="14.0"
 Build started 8/3/2015 9:27:34 AM.
      1>Project "C:\aac4a4f6\Root\src\MyProject.Api\MyProject.Api.xproj" on node 1 (Build;FileSystemPublish target(s)).
      1>PrepareForBuild:
          Creating directory "..\artifacts\bin\MyProject.Api\".
          Creating directory "..\artifacts\obj\MyProject.Api\any cpu\release\".
        PreComputeCompileTypeScript:
          C:\Program Files (x86)\Microsoft SDKs\TypeScript.4\tsc.exe  --noEmitOnError COMPUTE_PATHS_ONLY
        CompileTypeScript:
        Skipping target "CompileTypeScript" because it has no outputs.
        CoreCompile:
          C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\dnx.exe --appbase "C:\aac4a4f6\Root\src\MyProject.Api" "C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\lib\Microsoft.Framework.PackageManager\Microsoft.Framework.PackageManager.dll" pack "C:\aac4a4f6\Root\src\MyProject.Api" --configuration release --out "..\artifacts\bin\MyProject.Api"
          Microsoft .NET Development Utility CLR-x86-1.0.0-beta6-12256
          Building MyProject.Api for DNX,Version=v4.5.1
            Using Project dependency MyProject.Api 1.0.0
              Source: C:\aac4a4f6\Root\src\MyProject.Api\project.json
            Using Project dependency MyProject.Domain.Model 1.0.0
              Source: C:\aac4a4f6\Root\src\MyProject.Domain.Model\project.json
            ... (deleted for readability)
            Using Assembly dependency framework/fx/mscorlib 4.0.0.0
              Source: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll
            Using Assembly dependency framework/fx/System 4.0.0.0
              Source: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.dll
            ... (deleted for readability)
          The following commands will not be exported for global install: web.
          MyProject.Api -> C:\aac4a4f6\Root\src\artifacts\bin\MyProject.Api\release\MyProject.Api.1.0.0.nupkg
          MyProject.Api -> C:\aac4a4f6\Root\src\artifacts\bin\MyProject.Api\release\MyProject.Api.1.0.0.symbols.nupkg
          Build succeeded.
              0 Warning(s)
              0 Error(s)
          Time elapsed 00:00:09.0953302
          Total build time elapsed: 00:00:09.1660739
          Total projects built: 1
        GetTypeScriptCopyToOutputDirectoryItems:
          Adding items with BuildAction=TypeScriptCompile to the same collections that will be populated (with items of other BuildActions) by the GetCopyToOutputDirectoryItems target
        GatherAllFilesToPublish:
          Environment variables:
          Path=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\extensions\microsoft\web tools\external;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files\Microsoft SQL Server0\DTS\Binn\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\Windows Kits.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript.0\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Users\VssAdministrator\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Microsoft Emulator Manager.0\;C:\Program Files (x86)\GtkSharp.12\bin;C:\Program Files (x86)\Microsoft SDKs\TypeScript.4\;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server0\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server0\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\NPM\Modules;C:\Program Files\nodejs\;C:\NPM\Modules;C:\cordova;C:\java\ant\apache-ant-1.9.4\bin;;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\extensions\microsoft\web tools\external\.git
          C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\dnu.cmd publish "C:\aac4a4f6\Root\src\MyProject.Api" --out "C:\aac4a4f6\Root\MyProject\artifacts\bin\release\Publish" --configuration release --runtime dnx-clr-win-x86.1.0.0-beta6 --quiet
          Microsoft .NET Development Utility CLR-x86-1.0.0-beta6-12256
          Copying to output path C:\aac4a4f6\Root\MyProject\artifacts\bin\release\Publish
          Time elapsed 00:00:07.6405449
      1>Done Building Project "C:\aac4a4f6\Root\src\MyProject.Api\MyProject.Api.xproj" (Build;FileSystemPublish target(s)) -- FAILED.
 Build FAILED.
     0 Warning(s)
     0 Error(s)
 Time Elapsed 00:00:19.07
 ##[error]Unexpected exit code received from msbuild.exe: 1

global.json:

{
  "sources": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-beta6",
    "runtime": "clr",
    "architecture": "x86"
  }
}

project.json:

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta6",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta6",
    "Microsoft.AspNet.Mvc": "6.0.0-beta6"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini"
  },

  "frameworks": {
    "dnx451": { }
  },

  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ]
}

编辑:

从 msbuild.exe 中删除以下参数会导致构建成功:

/t:Build,FileSystemPublish /p:PublishConfiguration=release /p:PublishOutputPathNoTrailingSlash=C:\aac4a4f6\Root\MyProject\artifacts\bin\release\Publish

我的发布参数显然有问题。

我发现了问题。

以下抛出异常:

dnu.cmd publish "C:\aac4a4f6\Root\src\MyProject.Api" --out "C:\aac4a4f6\Root\MyProject\artifacts\bin\release\Publish" --configuration release --runtime dnx-clr-win-x86.1.0.0-beta6 --quiet

我 运行 它没有 --quiet 参数,结果是 ArgumentNullException:

Restoring packages for C:\aac4a4f6\Root\src\RelatedProject\project.json
----------
System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at Microsoft.Framework.Runtime.Project.GetTargetFramework(FrameworkName targetFramework)
   at Microsoft.Framework.Runtime.ProjectReferenceDependencyProvider.GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
   at Microsoft.Framework.PackageManager.LocalWalkProvider.FindLibrary(LibraryRange libraryRange, FrameworkName targetFramework, Boolean includeUnlisted)
   at Microsoft.Framework.PackageManager.RestoreOperations.<FindProjectMatch>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibraryMatch>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibraryEntry>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreOperations.<CreateGraphNode>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreCommand.<CreateGraphNode>d__71.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Framework.PackageManager.RestoreCommand.<RestoreForProject>d__70.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreCommand.<>c__DisplayClass69_0.<<Execute>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreCommand.<Execute>d__69.MoveNext()
----------
Restore failed
Value cannot be null.
Parameter name: key

我删除了项目依赖项,现在可以使用了。我不知道例外意味着什么。发布了关于 .

的问题

我也遇到了这个问题。如果有人遇到类似问题,我将发布此答案,然后尝试此解决方案。我的 visual studio 解决方案具有针对不同版本的 .NET Framework 的项目(一个项目 .NET 4.5.1 和其他项目 .NET 4.5.2)。它还有一个目标平台设置为 Sql Server 2016 的数据库项目。

我必须确保我的解决方案中的所有项目都以 .NET 4.5.2 为目标,并且数据库项目的目标平台设置为 Sql Server 2012。这是因为我们的构建服务器具有不同版本的 Visual studio安装。因此,检查目标框架是否适用于您的项目,以及您是否有数据库项目,然后确保它们针对 Sql 服务器的正确版本。