whats the difference between Developer and MSbuild Command prompt?which one do you use for general purpose application building?does it matter on which to use and how?
To put simply, the difference is what commands are available. For the most part, though, you can consider the Visual Studio Developer Command Prompt as being a super-set to the MSBuild command prompt. The Visual Studio Developer Command Prompt just adds additional settings such as adjusts %PATH% to include Visual Studio tooling, performance tools, TypeScript compiler, runs dnvm setup, and a few other things.
If you're really curious, have a look in the C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools directory for VsMSBuildCmd.bat and VsDevCmd.bat.
Related
I have installed VS2017 and call
call "%VS120COMNTOOLS%VSVars32.bat"
from the command line but all I get is
'"%VS150COMNTOOLS%VSVars32.bat"' is not recognized as an internal or external command, operable program or batch file.
If I run "set" from the command line I can see VS120COMNTOOLS (for VS2013) & VS140COMNTOOLS (for VS2015) but there is no VS150COMNTOOLS. How can I build from the command line?
I submitted this as a tech support issue to Microsoft who accepted it as a bug in the install ("there is no VSVars32.bat in the C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools directory.").
However, there is a work-around:
From MS:
At least, since there is a VsDevCmd.bat, there is a Visual Studio 2017 Developer Command Prompt, which also sets, modifies environment variables (Framework40Verion, FrameworkDir, FrameworkDIR64, FrameworkVersion, FrameworkVersion64, INCLUDE, IPCPATH, PATH, VCINSTALLDIR, VCToolsInstallDir, ...)
C:\Program Files (x86)\Microsoft Visual Studio\2017\EDITION\Common7\Tools\VsDevCmd.bat
Run C:\Program Files (x86)\Microsoft Visual Studio\2017\EDITION\Common7\Tools\VsDevCmd.bat where EDITION is the type of VS2017 install, i.e. C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat for the Enterprise install. This sets up the needed environment variables and batch builds will work.
Hope this helps anyone struggling with the same issue.
VS2017 has reworked its directory structure and filenames. The file is no longer titled "VsVars32.bat", you should look for the file 'vcvars.bat', which can be located in ..\Program Files (x86)\Microsoft Visual Studio\2017\EDITION\Common7\Tools\vsdevcmd\ext\vcvars.bat (using Adam's syntax, replace EDITION with the version of Visual Studio you use).
For simplicity, you can use %VSAPPIDDIR% in your call to point to the IDE folder where devenv.exe is located, and go back one folder to define your path to the batch file. For example:
call "%VSAPPIDDIR%..\Tools\vsdevcmd\ext\vcvars.bat"
If its any help to anyone...
If you modify your Visual Studio 2017 installation to install the component:
"VC++ 2015.3 v140 toolset for Desktop (x86,x64)"
then the 'VSVars32.bat' file which is missing, will be installed (as its a component of VC++ 2015, but not VC++ 2017).
I wrote a simple C# file. When I compile it using command prompt, I get an error
'csc' is not recognized as an internal or external command, operable program or batch file.
Do I need to set an environment variable?
When you install Visual Studio it comes with it a batch file that sets up the environment for you and opens a cmd window. It's called Developer Command Prompt for VS201x (where x is the Visual Studio version you have). It is located in the Visual Studio Tools menu, usually at:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Visual Studio 201x\Visual Studio Tools
This is the result:
EDIT:
If you don't have Visual Studio installed you can still access the C# compiler shipped with the .NET Framework in Windows 8. You will find it in:
C:\Windows\Microsoft.NET\Framework\v4.0.30319
Otherwise you can install it manually. Here is the link
What you need to do after is just adding it to your environment variable path
Hope it helps.
I was wondering why Visual Studio won't do what it's been told as I recognized, that Visual Studio just uses the standard Windows Command Prompt and not its own VS Cmd Prompt.
This results in an
'csc' is not recognized as an internal or external command
error message in the build output window.
So.. is there a way to tell VS to use its own command line tool where csc is usable or do I really have to set additional system variables to get this run?
The easiest way is probably just call out to the thing the normal VSXXXX command prompt uses:
Ex:
CALL ""%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
(edit: updated as per Hans's comment)
I have a few classes with the same namespace, and I want to put all of them in a dll file, and use it in other places.
I read the guide on Microsoft's website:
http://msdn.microsoft.com/en-us/library/3707x96z(v=vs.80).aspx
They suggested this:
To build the file [myDllName].DLL, compile the two files [myClass1].cs and
[myClass2].cs using the following command line:
csc /target:library /out:[myDllName].DLL [myClass1].cs [myClass2].cs
I wrote it in a cmd window and got an error that there is no such command as csc.
Plus, how it will find my files without a path?
So what is the right way of doing it? Where should I write it?
I saw some posts here with Library classes.. but not sure how it can help me.
My classes are in a different solution, and I just want to use it as an external dll, and not within the same solution.
In this case, Microsoft's guide seems perfect, if it will work.
If you use the Visual Studio Command Prompt window, all the necessary environment variables are set for you. In Windows 7, you can access that window from the Start menu by opening the Microsoft Visual Studio Version\Visual Studio Tools folder. In Windows 8, the Visual Studio Command Prompt is called the Developer Command Prompt for VS2012, and you can find it by searching from the Start screen.
source
You can run the vsvars batch file from a command prompt and it will set paths for you, for that instance of cmd.exe
Mine is here:
>"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat"
Why don't you just create a separate 'Class Library' project in your solution in Visual Studio?
You can than easily add it as a project reference to all other projects that need it.
You can create Solution Folders in VS to logically group projects.
Make sure csc.exe is in your PATH environment variable.
You should have a vsvars32.bat that was installed with Visual Studio. You can run that to automatically add it to the path, or dig down in regedit to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
Look through the subtrees in there for your framework version, and for an InstallPath key. That should tell you what directory to look in.
You can then use that, and:
WHERE /r "the_directory_you_found" csc.exe
to find the path. Add that to your system environment variables, and you should be able to find it.
As for the path of the class files, either run the command from the directory they're in, or specify the path when specifying the class files.
If you have Visual Studio installed, you could try creating a 'Class Library' project; Or you can run csc.exe by Launching "Visual Studio Command Prompt".
If you don't have Visual Studio installed but have .net framework installed. You can run csc.exe from the framework installation directory.
Installation directory path for .net Framework 4.0 :
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
I'm using Visual Studio 2008 to write an installation, and I'm a completely new to installations. I've created an installation and successfully written some custom actions using a C# assembly. One action sets a RunOnce registry value, and now I need to prompt the user to reboot when the installation finishes, but I have no idea how. I've read the Installer class documentation, but I can't find any mention of rebooting.
I'm assuming I need to somehow get down to being able to call MsiSetProperty and set a REBOOT property, but I don't know how to do that from my .NET installer project.
Thanks. I ended up using a post-build event to run a batch file with the following command. The hard part was tracking down WiRunSQL.vbs, which was in the "Windows SDK Components for Windows Installer Developers" download.
cscript "C:\Program Files\Microsoft SDKs\Windows\v6.0\Samples\SysMgmt\MSI\scripts\WiRunSQl.vbs" my.msi "INSERT INTO `Property`(`Property`, `Value`) VALUES ('REBOOT', 'F')"
If you are implementing your installer using WiX, you need to add this:
<ScheduleReboot After="InstallFinalize"/>
If you're using the cut-down "Installer" project in Visual Studio, I'm not sure... But this link here suggests a CScript command that seems to show how to inject an MSI property into the installer project, much as you want to do.
Just set the property in the MSI initally, rather than trying to update it at runtime.
Visual Studio 2008 ships with WiX anyway, see Visual Studio ships the WiX toolset for more details. That said, I'm not a Visual Studio 2008 user, so I don't know if that's in addition, or in replacement to the previous Visual Studio setup projects.