从命令行构建一个.sln / .vcxproj项目,并使用Visual C 的免费版本构建
Build a .sln / .vcxproj project from command line with a free edition of Visual C++
如果我不想使用Visual Studio IDE的功能,是否可以安装非时限/non-non-30--Microsoft C 编译器(哪个版本?(和直接从命令行?
直接构建.sln或.vcxproj project这是我成功用于单个.cpp文件项目的方法:
call "C:Program Files (x86)Microsoft Visual Studio 12.0VCvcvarsall.bat" x86
cl helloworld.cpp /link user32.lib
有没有办法将其扩展到.sln或.vcxproj项目?
我对此使用devenv
。请注意,至少在VS 2017社区中,您必须打开VS GUI并使用Microsoft帐户登录,否则它将在30天后停止允许编译。
PATH=%PATH%;C:Program Files (x86)Microsoft Visual Studio2017CommunityCommon7IDE
devenv Solution.sln /build Debug /project project
(即使您不运行vcvarsall.bat
,这也有效,这很好(
如果我们要不是使用IDE,则可以仅安装VS构建工具(安装程序为VS2019命名为vs_BuildTools.exe
(,然后只使用msbuild
。
示例:https://learn.microsoft.com/en-us/cpp/cpp/build/walkthrough-using-msbuild-to-to-create-create-a-visual-cpp-project?view = mmsvc-160
build.bat:
MSBuild.exe helloworld.vcxproj /p:configuration=release /p:platform=x64
helloworld.vcxproj:
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<Import Project="$(VCTargetsPath)Microsoft.Cpp.default.props" />
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)Microsoft.Cpp.props" />
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)Microsoft.Cpp.Targets" />
</Project>
main.cpp:
#include <iostream>
#include "main.h"
int main()
{
std::cout << "Hello, from MSBuild!n";
return 0;
}
和一个空的main.h文件。
在这种情况下确实需要.sln文件。
相关文章:
- 在Windows 10上使用Visual Studio 2019构建的Tesseract API c ++程序在Wind
- Visual Studio C++ 它只构建选项卡中显示的文件吗?
- 使用 Visual Studio 2019 构建 Hello World wxwidgets 应用程序时出错
- 无法在 Visual Studio 2010 中构建 Allegro C++ 程序
- 在 Boost::fiber 中引发的BOOST_ASSERT故障 Visual Studio "Debug" 构建
- Visual Studio 2019编译和构建
- 默认/样板代码在Visual Studio 2017中给我错误.E1574.虚幻.但构建成功了
- Visual Studio 2019:使用 vcvars64 从命令行构建C++.bat不再工作
- 在 Visual Studio 中构建一个没有 C/C++ 运行时的静态库
- 在Visual Studio 2017中使用c ++组件构建python解决方案时出现问题
- 在Visual Studio 2017中构建Qt可执行文件
- 所有Visual Studio安装程序崩溃,可视化构建工具也无法正常工作
- Bullet Physics源代码未在X86中构建 - Visual Studio 2017中错误的预处理器指令
- 从命令行构建Visual Studio Express 11项目
- 如何在Linux下构建Visual Studio解决方案
- 从命令行构建Visual Studio 2008解决方案
- 如何在Gradle下构建Visual Studio项目
- 在目录中的文件子集上构建visual studio项目
- 在没有 Visual Studio 的情况下构建 Visual Studio 6 项目
- 如何处理和包含头文件和库,以便在不同的机器上构建Visual Studio 2010解决方案