Cordova Windows生成“未检测到所选目标的有效MSBuild”

Cordova Windows生成“未检测到所选目标的有效MSBuild”,windows,visual-studio,cordova,msbuild,Windows,Visual Studio,Cordova,Msbuild,我试图在Windows 10上构建我的cordova应用程序,但由于我猜选择的路径,它失败了。我已安装Visual Studio 2017,并希望在以下位置选择msbuild路径:C:\Program Files x86\Microsoft Visual Studio\2017\Enterprise\msbuild\15.0\Bin,但进程始终使用C:\Program Files x86\msbuild\14.0\Bin来生成应用程序。 我不确定究竟是什么问题,如果路径是问题,或者版本有任何问题

我试图在Windows 10上构建我的cordova应用程序,但由于我猜选择的路径,它失败了。我已安装Visual Studio 2017,并希望在以下位置选择msbuild路径:C:\Program Files x86\Microsoft Visual Studio\2017\Enterprise\msbuild\15.0\Bin,但进程始终使用C:\Program Files x86\msbuild\14.0\Bin来生成应用程序。 我不确定究竟是什么问题,如果路径是问题,或者版本有任何问题。该应用程序不是由我开发的,因此我不太熟悉问题的产生地点和原因

我已经尝试更改Windows路径变量,但它不会影响生成过程。我也从Visual Studio 2019切换到2017,因为不再支持cordova build

我的CordovaApp.Windows10.jsproj文件:

这是我的控制台输出:

我自己解决的。
使用>cordova prepare命令生成windows平台,包括Visual Studio的.sln文件和.jsproj文件,我将目录更改为CordovaApp.Windows10.jsproj所在的\app\platforms\windows。在执行>MSBuild CordovaApp.Windows10.jsproj之后,我收到了一条更清晰的错误消息,在修复之后,我得到了完成的生成。

如果使用VS2017的开发人员命令提示符进行生成,结果如何?尝试将Toolsversion更改为15.0。感谢您的回答,我用另一种方法解决了这个问题,但通过使用开发者命令提示符,构建也可以使用“cordova build windows”命令完成。嗨,Thomas,感谢您的分享,请将您的回复标记为答案,这将帮助其他社区成员更轻松地搜索此有用信息。看到它只是提醒:嗨,托马斯,谢谢你的分享,你可以考虑把它标记为答案,这表明这个问题得到解决。它还将帮助其他社区成员更容易地搜索这些有用的信息。见:
<?xml version='1.0' encoding='utf-8'?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <OutputPath>build\windows\$(Configuration)\$(Platform)\win10\</OutputPath>
        <IntermediateOutputPath>build\windows\bld\</IntermediateOutputPath>
        <AppxPackageSigningEnabled>true</AppxPackageSigningEnabled>
    </PropertyGroup>
    <ItemGroup Label="ProjectConfigurations">
        <ProjectConfiguration Include="Debug|AnyCPU">
            <Configuration>Debug</Configuration>
            <Platform>AnyCPU</Platform>
        </ProjectConfiguration>
        <ProjectConfiguration Include="Debug|ARM">
            <Configuration>Debug</Configuration>
            <Platform>ARM</Platform>
        </ProjectConfiguration>
        <ProjectConfiguration Include="Debug|x64">
            <Configuration>Debug</Configuration>
            <Platform>x64</Platform>
        </ProjectConfiguration>
        <ProjectConfiguration Include="Debug|x86">
            <Configuration>Debug</Configuration>
            <Platform>x86</Platform>
        </ProjectConfiguration>
        <ProjectConfiguration Include="Release|AnyCPU">
            <Configuration>Release</Configuration>
            <Platform>AnyCPU</Platform>
        </ProjectConfiguration>
        <ProjectConfiguration Include="Release|ARM">
            <Configuration>Release</Configuration>
            <Platform>ARM</Platform>
            <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
        </ProjectConfiguration>
        <ProjectConfiguration Include="Release|x64">
            <Configuration>Release</Configuration>
            <Platform>x64</Platform>
            <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
        </ProjectConfiguration>
        <ProjectConfiguration Include="Release|x86">
            <Configuration>Release</Configuration>
            <Platform>x86</Platform>
            <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
        </ProjectConfiguration>
    </ItemGroup>
    <PropertyGroup Label="Globals">
        <ProjectGuid>f9b0ae20-c21c-42b9-9c4e-d8k328b4509e</ProjectGuid>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)' == 'Release'">
        <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
        <EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
        <Optimize>true</Optimize>
    </PropertyGroup>
    <PropertyGroup Condition="'$(CordovaBundlePlatforms)' != ''" Label="CordovaBuildParameters">
        <AppxBundle>Always</AppxBundle>
        <AppxBundlePlatforms>$(CordovaBundlePlatforms)</AppxBundlePlatforms>
    </PropertyGroup>
    <Import Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
    <PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0'">
        <VisualStudioVersion>14.0</VisualStudioVersion>
    </PropertyGroup>
    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
    <PropertyGroup>
        <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
        <TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
        <TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
        <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
        <UapDefaultAssetScale>100</UapDefaultAssetScale>
    </PropertyGroup>
    <PropertyGroup Condition="'$(VisualStudioVersion)' &lt; '14.0'">
        <TargetPlatformVersion>10.0</TargetPlatformVersion>
        <TargetPlatformMinVersion>10.0</TargetPlatformMinVersion>
    </PropertyGroup>
    <ItemGroup>
        <AppxManifest Include="package.windows10.appxmanifest">
            <SubType>Designer</SubType>
        </AppxManifest>
    </ItemGroup>
    <Import Label="Shared" Project="CordovaApp.projitems" />
    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
    <Target AfterTargets="ResolveAssemblyReferences" BeforeTargets="AfterResolveReferences" Condition="'$(Platform)' == 'AnyCPU'" Name="DetectMangedWinMDWithAnyCpu">
        <Error Condition="'%(_ResolveAssemblyReferenceResolvedFiles.WinMDFile)' == 'true' AND '%(_ResolveAssemblyReferenceResolvedFiles.WinMDFileType)' == 'Managed'" Text="The following component requires .NET Native compilation which is not available when targeting 'Windows10' and 'AnyCPU'. Consider changing the targeted processor architecture to one of the following: 'x86, x64, ARM' (if you are using command line this could be done by adding '--archs' parameter, for example: 'cordova build windows --archs=x64'). %(_ResolveAssemblyReferenceResolvedFiles.Identity)" />
    </Target>
    <PropertyGroup>
        <PreBuildEvent>node "$(ProjectDir)\\cordova\\prebuild-10.js"</PreBuildEvent>
        <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
    </PropertyGroup>
</Project>
Building project: C:\Users\Thomas\Desktop\output-win\platforms\windows\CordovaApp.Windows10.jsproj
        Configuration : debug
        Platform      : x86
        Buildflags    : /p:CordovaBundlePlatforms=x86
        MSBuildTools  : C:\Program Files (x86)\MSBuild\14.0\bin
buildProject spawn: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild [ 'C:\\Users\\Thomas\\Desktop\\output-win\\platforms\\windows\\CordovaApp.Windows10.jsproj',  
  '/clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal',
  '/nologo',
  '/p:Configuration=debug',
  '/p:Platform=x86',
  '/p:CordovaBundlePlatforms=x86' ] { stdio: 'inherit' }
C:\Users\Thomas\Desktop\output-win\platforms\windows\CordovaApp.Windows10.jsproj(61,5): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Mi 
crosoft\VisualStudio\v14.0\Microsoft.VisualStudio..Default.props" was not found. Make sure that the path in the <Import> declaration is correct.  
and the file exists on the disk.
No valid MSBuild was detected for the selected target: Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe: Command failed with exit code 1