MSWild在UWP项目

时间:2017-02-07 14:52:26

标签: msbuild uwp

我在我的解决方案中有两个项目,MyProject.Core和MyProject.UnitTests,它们都是UWP。从VS我可以毫无问题地构建和运行它们,但是当我尝试从命令行构建UnitTests项目时,使用MSBUILD.exe我得到了这个错误:

C:\ Program File x86)\ MSBuild \ Microsoft \ NuGet \ Microsoft.NuGet.targets(140,5):错误:您的project.json未将“win10”列为目标运行时。你应该在你的project.json中的“runtimes”部分添加'“win10”:{}',a d然后重新运行NuGet恢复

错误完全是误导。我注意到当我删除对Core项目的引用时,它确实有效。我认为它与Core项目的引用有关。我试过手动添加它们,但没有运气。

以下是完整的控制台输出:

GetInstalledSDKLocations:   正在搜索针对“UAP,10.0.14393.0”的SDK。   正在搜索针对“Windows,8.1”的SDK。 ResolveSDKReferences:     读取SDK清单文件“C:\ Program Files(x86)\ Microsoft SDKs \ Windows Kits \ 10 \ ExtensionSDKs \ MSTestFramework.Universal \ 14.0 \ SDKManifest.xml”。     目标配置和架构“零售| x86”     SDK清单中未找到FrameworkIdentity属性,将此SDK视为非框架SDK。     SDK清单中未找到指示应用程序包位置的“APPX”属性。如果在运行时需要应用程序包,则项目可能无法运行。     读取SDK清单文件“C:\ Program Files(x86)\ Microsoft SDKs \ Windows Kits \ 10 \ ExtensionSDKs \ TestPlatform.Universal \ 14.0 \ SDKManifest.xml”。     目标配置和架构“零售| x86”     SDK清单中未找到FrameworkIdentity属性,将此SDK视为非框架SDK。     SDK清单中未找到指示应用程序包位置的“APPX”属性。如果在运行时需要应用程序包,则项目可能无法运行。 ExpandSDKReferences:   从“C:\ Program Files(x86)\ Microsoft SDKs \ Windows Kits \ 10 \ ExtensionSDKs \ MSTestFramework.Universal \ 14.0 \”枚举SDK参考“MSTestFramework.Universal,Version = 14.0”。   添加引用“References \ CommonConfiguration \ neutral \ Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AppContainer.dll”。   添加引用“References \ CommonConfiguration \ neutral \ Microsoft.VisualStudio.TestPlatform.UnitTestFramework.dll”。   使用目标路径“Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter.dll”从redist文件夹添加文件“Redist \ CommonConfiguration \ neutral \ Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter.dll”。   从“C:\ Program Files(x86)\ Microsoft SDKs \ Windows Kits \ 10 \ ExtensionSDKs \ TestPlatform.Universal \ 14.0 \”枚举SDK参考“TestPlatform.Universal,Version = 14.0”。   添加引用“References \ CommonConfiguration \ neutral \ Microsoft.VisualStudio.TestPlatform.TestExecutor.Core.dll”。   使用目标路径“vstest.executionengine.WindowsPhone.dll”从redist文件夹添加文件“Redist \ CommonConfiguration \ x86 \ vstest.executionengine.WindowsPhone.dll”。   从redist文件夹添加文件“Redist \ CommonConfiguration \ x86 \ vstest_executionengine_platformbridge.dll”,目标路径为“vstest_executionengine_platformbridge.dll”。   使用目标路径“Microsoft.VisualStudio.TestPlatform.Common.dll”从redist文件夹添加文件“Redist \ CommonConfiguration \ neutral \ Microsoft.VisualStudio.TestPlatform.Common.dll”。   使用目标路径“Microsoft.VisualStudio.TestPlatform.Core.dll”从redist文件夹添加文件“Redist \ CommonConfiguration \ neutral \ Microsoft.VisualStudio.TestPlatform.Core.dll”。   使用目标路径“Microsoft.VisualStudio.TestPlatform.ObjectModel.dll”从redist文件夹添加文件“Redist \ CommonConfiguration \ neutral \ Microsoft.VisualStudio.TestPlatform.ObjectModel.dll”。   从redist文件夹添加文件“Redist \ CommonConfiguration \ neutral \ vstest_executionengine_platformbridge.winmd”,目标路径为“vstest_executionengine_platformbridge.winmd”。 C:\ Program Files(x86)\ MSBuild \ Microsoft \ NuGet \ Microsoft.NuGet.targets(140,5):错误:您的project.json未将'win10'列为目标运行时。你应该在project.json中的“runtimes”部分添加“win10”:{}' 然后重新运行NuGet还原。

这是项目的project.json(目前它们都是相同的,因为我已经将Core的所有依赖项添加到单元测试项目中)

{
  "dependencies": {
    "CommonServiceLocator": "1.3.0",
    "HockeySDK.UWP": "4.1.6",
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
    "Microsoft.Xaml.Behaviors.Uwp.Managed": "2.0.0",
    "MvvmLight": "5.3.0",
    "MvvmLightLibs": "5.3.0",
    "Newtonsoft.Json": "9.0.1",
    "System.Reactive": "3.1.1"
  }, "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

1 个答案:

答案 0 :(得分:0)

要在命令行中重新创建Visual Studio可以成功执行的构建,请参阅https://msdn.microsoft.com/en-us/library/jj651643.aspx处的说明以查看VS使用的命令。

快速摘要:将构建输出详细程度设置为“诊断”