用资源管理器右键编译 Visual Studio 解决方案文件
每次改动 VC 工程之后都要重新编译,每次 VS 又会生成调试数据库文件,很费时间,于是研究了一下如何在资源管理器中直接编译,还真发现了解决办法。
以下是适用 Visual Studio 2008 的注册表文件,导入系统之后右键点 .sln 文件就会出来编译的菜单了:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell] [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Build Debug] @="使用 VCBuild 编译 Debug(&D)" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Build Debug\Command] @="cmd.exe /K \"\"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\vcbuild.exe\" \"%1\" \"Debug|Win32\"\"" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Bulild Release] @="使用 VCBuild 编译 Release(&R)" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Bulild Release\Command] @="cmd.exe /K \"\"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\vcbuild.exe\" \"%1\" \"Release|Win32\"\""
自 Visual Studio 2010 开始,微软使用 MSBuild 取代了 Visual C++ 的 VCBuild,所以方法有些不同:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell] [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Build Debug] @="使用 MSBuild 编译 Debug(&D)" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Build Debug\Command] @="cmd.exe /K \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe /m \"%1\" /p:Configuration=Debug /t:Build\"" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Bulild Release] @="使用 MSBuild 编译 Release(&R)" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Bulild Release\Command] @="cmd.exe /K \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe /m \"%1\" /p:Configuration=Release /t:Build\""
VS2013中右键编译CSharp项目
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\VisualStudio.Launcher.csproj.12.0\Shell] [HKEY_CLASSES_ROOT\VisualStudio.Launcher.csproj.12.0\Shell\Build Debug] @="使用 MSBuild 编译 Debug(&D)" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.csproj.12.0\Shell\Build Debug\Command] @="cmd.exe /K \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe /m \"%1\" /p:Configuration=Debug /t:Build\"" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.csproj.12.0\Shell\Bulild Release] @="使用 MSBuild 编译 Release(&R)" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.csproj.12.0\Shell\Bulild Release\Command] @="cmd.exe /K \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe /m \"%1\" /p:Configuration=Release /t:Build\""
VS2013中右键编译CPP项目
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\VisualStudio.Launcher.vcxproj.12.0\Shell] [HKEY_CLASSES_ROOT\VisualStudio.Launcher.vcxproj.12.0\Shell\Build Debug] @="使用 MSBuild 编译 Debug(&D)" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.vcxproj.12.0\Shell\Build Debug\Command] @="cmd.exe /K \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe /m \"%1\" /p:Configuration=Debug /t:Build\"" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.vcxproj.12.0\Shell\Bulild Release] @="使用 MSBuild 编译 Release(&R)" [HKEY_CLASSES_ROOT\VisualStudio.Launcher.vcxproj.12.0\Shell\Bulild Release\Command] @="cmd.exe /K \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe /m \"%1\" /p:Configuration=Release /t:Build\""
其他VS版本就自己对着注册表修改就是了,很方便。
注意:使用 MSBuild 的时候会检查环境变量“Platform”,如果不确定配置的是否正确,建议删除该环境变量即可(安装完 Visual Studio 会默认该变量指为 BNB,导致 MSBuild 无法正确编译,但若启动 Visual Studio IDE 来编译则不会存在此问题)。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
2011-04-14 .NET托管内存类应用的内存泄漏分析和诊断(转)
2011-04-14 Windows 性能监视器工具-perfmon(转)
2010-04-14 DragDrop 注册失败的解决方法