Msbuild 从代码生成WP8.0程序集

Msbuild 从代码生成WP8.0程序集,msbuild,visual-studio-2013,windows-phone,Msbuild,Visual Studio 2013,Windows Phone,我正在尝试用代码构建一个wp8.0项目。我正在使用Project类和Build方法,源代码是可用的 代码在使用VS 2012的Windows 8上运行,但当我升级到Windows 8.1和VS2013时,它停止了工作。我知道Microsoft在VS中更改并删除了.NET中的构建框架,但我仍然不确定为什么会发生这种情况,以及如何修复它 错误: C:\程序文件 (x86)\MSBuild\Microsoft\WindowsPhone\v8.0\Microsoft.WindowsPhone.Commo

我正在尝试用代码构建一个wp8.0项目。我正在使用Project类和Build方法,源代码是可用的

代码在使用VS 2012的Windows 8上运行,但当我升级到Windows 8.1和VS2013时,它停止了工作。我知道Microsoft在VS中更改并删除了.NET中的构建框架,但我仍然不确定为什么会发生这种情况,以及如何修复它

错误:

C:\程序文件 (x86)\MSBuild\Microsoft\WindowsPhone\v8.0\Microsoft.WindowsPhone.Common.targets(75,5): 错误MSB4127:未能完成“GetSilverlightFrameworkPath”任务 从程序集“C:\Program Files”实例化 (x86)\MSBuild\Microsoft\WindowsPhone\v8.0\Microsoft.Silverlight.WindowsPhone.Build.Tasks.dll”。 请验证任务程序集是否已使用相同版本生成 将Microsoft.Build.Framework程序集的 计算机和主机应用程序不缺少绑定 Microsoft.Build.Framework的重定向。无法强制转换类型为的对象 “Microsoft.Silverlight.Build.Tasks.GetSilverlightFrameworkPath”到 键入“Microsoft.Build.Framework.ITask”。C:\Program Files (x86)\MSBuild\Microsoft\WindowsPhone\v8.0\Microsoft.WindowsPhone.Common.targets(75,5): 错误MSB4060:已删除“GetSilverlightFrameworkPath”任务 声明或使用不正确,或在施工期间失败。检查 任务名称和程序集名称的拼写

更新:
通过使用VS2013编译WP 8.0的方式,在尝试从代码构建WP 8.0时会出现问题。

您会遇到此错误,因为
Microsoft.Silverlight.WindowsPhone.build.Tasks.dll
是包含
GetSilverlightFrameworkPath
的程序集,例如在Silverlight 4和5 SDK中:

// Decompiled with JetBrains decompiler
// Type: Microsoft.Silverlight.Build.Tasks.GetSilverlightFrameworkPath
// Assembly: Microsoft.Silverlight.Build.Tasks, Version=9.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 2E9B62C4-1C0C-4AAD-8CBE-F7E074602879
// Assembly location: C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v5.0

//omitted for brevity

namespace Microsoft.Silverlight.Build.Tasks
{
  public sealed class GetSilverlightFrameworkPath : Task
  {
    private const string SDKAssemblyFoldersExRegKey = "v5.0\\AssemblyFoldersEx";
    public const string SDKLibrariesRegKey = "v5.0\\AssemblyFoldersEx\\Silverlight SDK Client Libraries";
    public const string SDKRuntimeInstallPathRegKey = "SOFTWARE\\Microsoft\\Microsoft SDKs\\Silverlight\\v5.0\\ReferenceAssemblies";

    public string RegistryBase { get; set; }

    public string SilverlightPath { get; set; }

    public string[] SilverlightSDKPaths { get; set; }

    public string SilverlightRuntimeVersion { get; set; }

    public override bool Execute()
    {
      //omitted for brevity
    }

    private string GetSilverlightPath()
    {
      //omitted for brevity
    }

    private string GetSDKRuntimeVersion()
    {
      //omitted for brevity
    }

    private string[] GetAllSilverlightSDKPaths()
    {
      //omitted for brevity
    }
  }
}
但是,它在WP v8.0中的实现看起来确实非常不同:

// Decompiled with JetBrains decompiler
// Type: Microsoft.Silverlight.Build.Tasks.GetSilverlightFrameworkPath
// Assembly: Microsoft.Silverlight.WindowsPhone.Build.Tasks, Version=9.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 899BFFD0-786C-472A-8935-576EED0F4F90
// Assembly location: C:\Program Files (x86)\MSBuild\Microsoft\WindowsPhone\v8.0\Microsoft.Silverlight.WindowsPhone.Build.Tasks.dll

//omitted for brevity

namespace Microsoft.Silverlight.Build.Tasks
{
  public sealed class GetSilverlightFrameworkPath : Task
  {
    public string RegistryBase { get; set; }

    public string RuntimePathRegistryKey { get; set; }

    public string RuntimeVersionRegistryKey { get; set; }

    public string AdditionalRegistryBasePaths { get; set; }

    public string SilverlightPath { get; set; }

    public string[] SilverlightSDKPaths { get; set; }

    public string SilverlightRuntimeVersion { get; set; }

    public override bool Execute()
    {
         // omitted for brevity
    }

    private string GetSilverlightPath()
    {
      // omitted for brevity
    }

    private string GetSDKRuntimeVersion()
    {
      // omitted for brevity
    }

    internal string[] GetAllSilverlightSDKPaths()
    {
      // omitted for brevity
    }
}
因此,事情不起作用是很自然的

您需要做的是检查您在所有项目中引用的SDK版本是否相同

您在构建过程中尝试实例化的任务位于SL SDK 5中,而当前由于某种原因,构建过程正在尝试使用WP8.0 SDK

此外,您引用的代码是csproj的一部分,它:


你确定这是你想要的吗

可能也与你有关


如果你提供更多关于你实际项目的信息,它可能很容易修复。现在,很难判断一切是如何设置的。

很抱歉反应太晚。我想我希望我的所有项目都使用新的toolsversion(12.0)。但是如果没有它它也能工作。。。我会很高兴的。您可以尝试导入项目并使用“-s1-v1.9.0-ltrue”配置运行Google.api.Release吗。我正在处理我仍然不明白的问题。。。我会花更多的时间来调查,但看起来很奇怪。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">