Perform Visual Studio Build from MATLAB command prompt

9 ビュー (過去 30 日間)
Mohammed Samdani
Mohammed Samdani 2011 年 10 月 13 日
編集済み: Dushyant Dhundara 2016 年 5 月 27 日
Hi,
I want to build Visual Studio project from MATLAB, using devenv command. I can do the build from dos command prompt, but not from MATLAB command prompt
For example I tried
system('Set PATH=C:/Program Files/Microsoft Visual Studio 9.0/Common7/IDE;%PATH%');
[status result]= system('devenv example.sln /Rebuild "Debug -example|Win32"')
I also tried addpath command to set the path and used dos command instead of system, yet it did not work.
But If I put this command in batch file (.bat) call the batch file using system or dos command it works.
Any Clue why devenv command does not work from MATLAB command prompt.
Regards
MOS
  1 件のコメント
Dushyant Dhundara
Dushyant Dhundara 2016 年 5 月 27 日
編集済み: Dushyant Dhundara 2016 年 5 月 27 日
Hi I am having the same problem, I tried using your command and it doesn't work. I used the following line of code:
system('Set PATH=C:/Program Files/Microsoft Visual Studio 12.0/Common7/IDE;%PATH% && devenv Sample.sln /Rebuild "Debug -Sample|Win64"');
However, I changed Win32 to Win64 and in the Common7 Folder, I didn't see IDE folder but there is a folder called "Packages". I am using Visual Studio Community 2015 and MATLAB 2016a

サインインしてコメントする。

採用された回答

Jason Ross
Jason Ross 2011 年 10 月 13 日
Try putting "&&" between your commands and make them one. For example,
system('set path=... && devenv...')
Alternatively, calling the batch file will also work.
The reason this is happening has already been stated -- when you open a system() window, it sources a new shell that inherits the default environment. Subsequent shells get a new environment.
  1 件のコメント
Mohammed Samdani
Mohammed Samdani 2011 年 10 月 14 日
Thanks Jason, it worked.

サインインしてコメントする。

その他の回答 (1 件)

Titus Edelhofer
Titus Edelhofer 2011 年 10 月 13 日
Hi MOS,
my suspicion is as follows: the two system calls both run in different shells ("hidden command window"), so the PATH statement of the first is not carried over to the second. I guess the simplest would be to call your batch file using system(...).
Titus
  2 件のコメント
Kaustubha Govind
Kaustubha Govind 2011 年 10 月 13 日
+1
Mohammed Samdani
Mohammed Samdani 2011 年 10 月 14 日
Thanks Titus

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by