MSBuild命令行错误 - 未安装Silverlight 4 SDK

Ned*_*Ned 36 msbuild silverlight silverlight-4.0

我的MSBuild命令行如下:

msbuild e:\code\myProject.csproj /p:Configuration=Debug /p:OutputPath=bin/Debug /p:Platform=x86 /p:PlatformTarget=x86

该项目在VS2010中的开发机器上构建良好,但不是上面的命令.我正在运行Win 7 64位.我收到一条错误消息,说我没有安装Silverlight 4 SDK,但我确实如此.我已经阅读了一些帖子,你必须设置Platform = x86但无济于事.以下是完整的错误消息:

Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 6/8/2010 4:03:38 PM.
Project "E:\code\dashboards\MyProject2010\MyProject2010.Web\MyProject2010
.web.csproj" on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output fi
les are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with resp
ect to the input files.
CopyFilesToOutputDirectory:
  Copying file from "obj\Debug\MyProject.Web.dll" to "bin\Debug\MyProject.Web
  .dll".
  MyProject2010.web -> E:\code\dashboards\MyProject2010\MyProject2010.Web
  \bin\Debug\MyProject.Web.dll
  Copying file from "obj\Debug\MyProject.Web.pdb" to "bin\Debug\MyProject.Web
  .pdb".
Project "E:\code\dashboards\MyProject2010\MyProject2010.Web\MyProject2010
.web.csproj" (1) is building "E:\code\dashboards\MyProject2010\MyProject20
10.Client\MyProject2010.Client.csproj" (2) on node 1 (GetXapOutputFile target(
s)).
C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight
.Common.targets(104,9): error : The Silverlight 4 SDK is not installed. [E:\cod
e\dashboards\MyProject2010\MyProject2010.Client\MyProject2010.Client.cspr
oj]
Done Building Project "E:\code\dashboards\MyProject2010\MyProject2010.Clie
nt\MyProject2010.Client.csproj" (GetXapOutputFile target(s)) -- FAILED.

Done Building Project "E:\code\dashboards\MyProject2010\MyProject2010.Web\
MyProject2010.web.csproj" (default targets) -- FAILED.


Build FAILED.

"E:\code\dashboards\MyProject2010\MyProject2010.Web\MyProject2010.web.csp
roj" (default target) (1) ->
"E:\code\dashboards\MyProject2010\MyProject2010.Client\MyProject2010.Clie
nt.csproj" (GetXapOutputFile target) (2) ->
(GetFrameworkPaths target) ->
  C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlig
ht.Common.targets(104,9): error : The Silverlight 4 SDK is not installed. [E:\c
ode\dashboards\MyProject2010\MyProject2010.Client\MyProject2010.Client.cs
proj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.39

我感谢任何人的帮助.谢谢.

Ana*_*tts 23

我想出来了 - 在MSBuild中有一个设置,您可以为MSBuild选择x64或x86环境(在您设置MSBuild标志的同一页面中) - 将其设置为x86,一切都会正常工作.


The*_*tor 21

如果你因为版本的问题到达这里导致上述错误(即使你已经安装了Silverlight 4 SDK),那么为了实现相同的修复,你必须编辑你的Build Process模板:

转到"进程"选项卡,展开"3.Advanced"部分并找到第二个从底部设置("MSBuild Platform")并将其设置为X86,然后指示构建代理程序使用MS86的x86变体.

这与Paul Betts上面的回答一起解决了我的问题.

  • 也适用于tfs2013(也适用于Silverlight 5项目) (2认同)

sel*_*ary 20

我在运行时遇到了同样的问题: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe

简单地运行:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe


Gar*_*all 2

当我尝试设置 Windows 7 Phone SDK 时,我在 Windows 7 Ultimate 64 位版本上遇到了这个问题。SDK/工具包安装/修复的组合对我来说不起作用,所以我决定进一步调查一下。

通过放置一些<Message />构建任务,我发现 Software\Microsoft\Silverlight\4.0 中没有注册表项。对于 32 位部分和 Wow6432Node 部分都是如此。

因此,发现框架存储位置的几个构建目标的输出返回空白,随后导致许多其他目标失败。具体来说,_FullFrameworkReferenceAssemblyPaths 和 TargetFrameworkDirectory 属性未正确设置。

尽管完全厌恶所有建议,但我通过手动将值硬编码到 .targets 文件中来规避这个问题,如下所示:

<PropertyGroup>
    <_FullFrameworkReferenceAssemblyPaths>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0</_FullFrameworkReferenceAssemblyPaths>
    <TargetFrameworkDirectory>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone</TargetFrameworkDirectory>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

这不是我特别自豪的事情,但如果我想在开发方面取得任何进展,就必须这样做。我希望这对其他人有帮助。

  • 如果 (a) 您在注册表中准确指出了缺少的键应该在哪里,(b) 在 Microsoft.Silverlight.Common.targets 文件中的哪个位置添加了 &lt;PropertyGroup&gt; 以强制路径,那就太好了。 (2认同)