MSBUILD 无法使用混合平台构建解决方案?
MSBUILD cannot build solution with Mixed Platforms?
我正在升级批处理文件,现在需要恢复 nuget 并构建一个包含 c# x86 和 c++ Wind32 项目的解决方案 - 在添加 nuget 之前,它曾经很好地使用 devenv。解决方案是'Mixed Platforms'。我如何使用 MSBuild 执行此操作?我无法指定 x86,因为 Win32 c++ 项目无法构建。
这适用于 x64,
@ECHO OFF
call "C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
ECHO Bulding for x64!!!
ECHO Building Theo.sln...
msbuild Theo.sln /t:restore /t:build /p:Configuration=Debug /p:Platform=x64 /verbosity:quiet
但是因为这是混合平台,所以这不起作用!
call "C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86
ECHO Bulding for x86!!!
ECHO Building Theo.sln...
msbuild Theo.sln /t:restore /t:build /p:Configuration=Debug /p:Platform="Mixed Platforms" /verbosity:quiet
我收到错误 MSB4126:指定的解决方案配置“Debug|MixedPlatforms”无效。
MSBUILD cannot build solution with Mixed Platforms?
我认为您应该仔细检查您创建的混合平台。
我建议您可以用这种方式创建混合平台。如果您已经使用过这种方式,请仔细检查每一步。
解决方案
首先,移除或删除之前的Platform Mixed Platforms.
1)打开菜单构建-->配置管理器-->解决方案平台 将作用于整个解决方案。
还有,确保名字一致,没有拼写错误。
2)这样创建记得要selectx86
平台
然后使用x86
bat文件构建项目,在我这边,它运行良好。
==============================
更新 1
实际上,当您使用我的设置为 x86 的解决方案平台然后启用它时,它将更改 win32 c++ 项目以使用您预期的 win32
平台。而不是 x86
。你应该注意到这一点。
C++ 项目使用 Win32 作为平台而不是 x86。当您使用我的解决方案平台时,它会将 win32 c++ 项目更改为使用 Win32
平台。
或者你可以尝试用win32平台单独构建win32项目,测试能否构建成功。
请检查您是否对xxx.vcxproj
文件进行了任何修改,您应该仔细检查。
除了,我发现错误消息Debug|MixedPlatforms
并且它使用MixedPlatforms
而不是Mixed Platforms
而你的批处理文件使用/p:Platform="Mixed Platforms"
。这很奇怪。我认为你在你的解决方案中定义了错误的名称,你应该仔细检查它。
此外,您可以尝试调用C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\MSBuild.exe
来测试您的解决方案。
call "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\MSBuild.exe" x86
ECHO Bulding for x86!!!
ECHO Building test1.sln...
msbuild C:\Users\Administrator\source\repos\test1\test1.sln /t:restore /t:build /p:Configuration=Debug /p:Platform="Mixed Platforms"
我正在升级批处理文件,现在需要恢复 nuget 并构建一个包含 c# x86 和 c++ Wind32 项目的解决方案 - 在添加 nuget 之前,它曾经很好地使用 devenv。解决方案是'Mixed Platforms'。我如何使用 MSBuild 执行此操作?我无法指定 x86,因为 Win32 c++ 项目无法构建。
这适用于 x64,
@ECHO OFF
call "C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
ECHO Bulding for x64!!!
ECHO Building Theo.sln...
msbuild Theo.sln /t:restore /t:build /p:Configuration=Debug /p:Platform=x64 /verbosity:quiet
但是因为这是混合平台,所以这不起作用!
call "C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86
ECHO Bulding for x86!!!
ECHO Building Theo.sln...
msbuild Theo.sln /t:restore /t:build /p:Configuration=Debug /p:Platform="Mixed Platforms" /verbosity:quiet
我收到错误 MSB4126:指定的解决方案配置“Debug|MixedPlatforms”无效。
MSBUILD cannot build solution with Mixed Platforms?
我认为您应该仔细检查您创建的混合平台。
我建议您可以用这种方式创建混合平台。如果您已经使用过这种方式,请仔细检查每一步。
解决方案
首先,移除或删除之前的Platform Mixed Platforms.
1)打开菜单构建-->配置管理器-->解决方案平台 将作用于整个解决方案。
还有,确保名字一致,没有拼写错误。
2)这样创建记得要selectx86
平台
然后使用x86
bat文件构建项目,在我这边,它运行良好。
==============================
更新 1
实际上,当您使用我的设置为 x86 的解决方案平台然后启用它时,它将更改 win32 c++ 项目以使用您预期的 win32
平台。而不是 x86
。你应该注意到这一点。
C++ 项目使用 Win32 作为平台而不是 x86。当您使用我的解决方案平台时,它会将 win32 c++ 项目更改为使用 Win32
平台。
或者你可以尝试用win32平台单独构建win32项目,测试能否构建成功。
请检查您是否对xxx.vcxproj
文件进行了任何修改,您应该仔细检查。
除了,我发现错误消息Debug|MixedPlatforms
并且它使用MixedPlatforms
而不是Mixed Platforms
而你的批处理文件使用/p:Platform="Mixed Platforms"
。这很奇怪。我认为你在你的解决方案中定义了错误的名称,你应该仔细检查它。
此外,您可以尝试调用C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\MSBuild.exe
来测试您的解决方案。
call "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\MSBuild.exe" x86
ECHO Bulding for x86!!!
ECHO Building test1.sln...
msbuild C:\Users\Administrator\source\repos\test1\test1.sln /t:restore /t:build /p:Configuration=Debug /p:Platform="Mixed Platforms"