如何为 Visual Studio 命令提示符创建批处理文件

发布于 2024-11-04 19:06:07 字数 681 浏览 0 评论 0原文

我想为 Visual Studio 2008 x64 交叉工具命令提示符 创建一个批处理文件,以便在我的电脑中连续执行某些操作,以下是情况。

svn update
delete some files
MSBuild MySolutiuon.sln
delete some files
xcopy somefiles
MSBuild AutomateBuildConfiguration.xml /p:Configuration=Release
xcopy some files
delete somefiles
xcopy some files

create a Zip file if it is possible // it is not neccessary

我可以使用简单的命令提示符和 Visual Studio 命令提示符的 MSBuild 部分来完成大部分工作,但是由于这两个提示符不同,我无法完成我的 senario。

我已经测试了所有命令并且对我来说非常有用,如果您知道我应该做什么,请给我一个解决方案。

我检查了这个并且不明白任何东西 先感谢您

I want to create a batch file for Visual Studio 2008 x64 Cross Tools Command Prompt to do something continuesly in my PC, here is the senario.

svn update
delete some files
MSBuild MySolutiuon.sln
delete some files
xcopy somefiles
MSBuild AutomateBuildConfiguration.xml /p:Configuration=Release
xcopy some files
delete somefiles
xcopy some files

create a Zip file if it is possible // it is not neccessary

I can do most of it with simple Command Prompt and MSBuild parts with Visual Studio Command Prompt, but as these two prompt are different I cannot complete my senario.

I have tested all command and work great for me, Give me a solution if you know what should I do.

I checked this and didn't underestand anything
Thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

余生再见 2024-11-11 19:06:07

让批处理文件的第一行设置 VS 环境:

call "C:\Program Files\Microsoft Visual Studio 2008\VC\vcvarsall.bat" x86_amd64
svn update
delete some files
MSBuild MySolutiuon.sln
... more commands ...

x86_amd64 是用于 x64 交叉工具命令提示符的参数。

运行 vcvarsall.bat 后,msbuild 将在批处理文件中其余命令的路径中可用。

或者,如果您不使用 Visual C++,您可能更愿意使用此行设置环境(而不是调用 vcvarsall.bat):

For VS 2008:

call "%vs90comntools%vsvars32.bat"

For VS 2010:

call "%vs100comntools%vsvars32.bat"

For VS 2012:

call "%vs110comntools%vsvars32.bat"

For VS 2013:

call "%vs120comntools%vsvars32.bat"

For VS 2015:

call "%vs140comntools%vsvars32.bat"

对于 VS 2017:

Batch 现在称为 vc,而不是 vs

call "%vs140comntools%\..\..\VC\Auxiliary\Build\vcvars32.bat"

或更好

call "%vs140comntools%\VsDevCmd.bat"

Make the first line of your batch file set up the VS environment:

call "C:\Program Files\Microsoft Visual Studio 2008\VC\vcvarsall.bat" x86_amd64
svn update
delete some files
MSBuild MySolutiuon.sln
... more commands ...

x86_amd64 is the argument used for x64 Cross Tools Command Prompt.

Once vcvarsall.bat has run, msbuild will be available in the path for the rest of the commands in your batch file.

Alternatively, if you aren't using Visual C++, you might prefer to set up the environment with this line (instead of the call to vcvarsall.bat):

For VS 2008:

call "%vs90comntools%vsvars32.bat"

For VS 2010:

call "%vs100comntools%vsvars32.bat"

For VS 2012:

call "%vs110comntools%vsvars32.bat"

For VS 2013:

call "%vs120comntools%vsvars32.bat"

For VS 2015:

call "%vs140comntools%vsvars32.bat"

For VS 2017:

Batch is now called vc not vs.

call "%vs140comntools%\..\..\VC\Auxiliary\Build\vcvars32.bat"

or better

call "%vs140comntools%\VsDevCmd.bat"
陪我终i 2024-11-11 19:06:07

对于 Visual Studio 2015

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64

对于 Visual Studio 2013

call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64

For Visual Studio 2015:

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64

For Visual Studio 2013:

call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64
↙厌世 2024-11-11 19:06:07

对于 Visual Studio 2010,这非常有效:

call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86

For Visual Studio 2010, this is working great:

call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
上课铃就是安魂曲 2024-11-11 19:06:07

对于Visual Studio 2019

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64

For Visual Studio 2019 :

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
帝王念 2024-11-11 19:06:07

对于 Visual Studio 2012:

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86_amd64

And for Visual Studio 2012:

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86_amd64
不可一世的女人 2024-11-11 19:06:07

我按照以下步骤编写了一个bat文件,并且成功了。

call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64
echo call complete
pause
cd C:\tfs.sbdinc.com
tf get $/MAC_MBA/CoreApplicationAndReports/Main/Application/Solution /recursive
echo get complete
pause
cd C:\tfs\CoreApplicationAndReports\Main\Application\Solution
msbuild
echo build complete
pause
devenv mba.sln
echo ide launch complete
pause

I wrote a bat file using the following steps and it worked.

call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64
echo call complete
pause
cd C:\tfs.sbdinc.com
tf get $/MAC_MBA/CoreApplicationAndReports/Main/Application/Solution /recursive
echo get complete
pause
cd C:\tfs\CoreApplicationAndReports\Main\Application\Solution
msbuild
echo build complete
pause
devenv mba.sln
echo ide launch complete
pause
贱贱哒 2024-11-11 19:06:07

尝试下面的批处理文件来运行 MS 测试/Nunit 测试以进行 C# 测试。

@echo off
echo Run the CMD(Command Prompt) Program.
echo.
pause
cls
echo Target Framwork
CD C:\Windows\Microsoft.NET\Framework64\v4.0.30319
echo 'Project Path'
msbuild  "C:\Git\ElementsCloud.Tests\Source\ElementsCloud.Tests.sln"/p:configuration=debug
pause
echo 'Project Dll path' and Execute tests
cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow
vstest.console.exe "C:\Git\ElementsCloud.Tests\Source\Selenium.Tests\bin\Debug\net471\Selenium.Tests.dll" /Tests:Test1,Test2,Test3
echo. 
PAUSE
EXIT

Try below batch file to run the MS test/Nunit test for C# tests.

@echo off
echo Run the CMD(Command Prompt) Program.
echo.
pause
cls
echo Target Framwork
CD C:\Windows\Microsoft.NET\Framework64\v4.0.30319
echo 'Project Path'
msbuild  "C:\Git\ElementsCloud.Tests\Source\ElementsCloud.Tests.sln"/p:configuration=debug
pause
echo 'Project Dll path' and Execute tests
cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow
vstest.console.exe "C:\Git\ElementsCloud.Tests\Source\Selenium.Tests\bin\Debug\net471\Selenium.Tests.dll" /Tests:Test1,Test2,Test3
echo. 
PAUSE
EXIT
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文