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.
Related
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.
I have cloned a project to my computer using TFS, when I build the project I get this error :
Error 6 Task could not find "LC.exe" using the SdkToolsPath "" or the
registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft
SDKs\Windows\v8.1A\WinSDK-NetFx40Tools-x86". Make sure the
SdkToolsPath is set and the tool exists in the correct processor
specific location under the SdkToolsPath and that the Microsoft
Windows SDK is installed
I have searched the web but couldn't find a solution. I use VS 2013 and .NET 4.
How can I fix this? Thanks.
If you're using MSBuild.exe to build projects from the command line, you can pass TargetFrameworkSDKToolsDirectory as a parameter to avoid having to edit your .csproj files.
For example:
MSBuild.exe mysolution.sln /t:build /p:TargetFrameworkSDKToolsDirectory="C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools"
It turns out you can specify the path to the SDK directly in the .csproj file:
<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools</TargetFrameworkSDKToolsDirectory>
and the build found lc.exe that way.
So do a dir /s for lc.exe and use that path.
I previously expected to set this using <SdkToolsPath>, but that didn't work. In Microsoft.Common.targets, SdkToolsPath gets set from TargetFrameworkSDKToolsDirectory, so I tried that and it worked. (It would be nice if the variable name corresponded 1 to 1, but they don't.)
This is on Visual Studio 2015, and msbuild being called from ant.
I was having the same problem and resolved it by re-installing the Visual Studio.
http://msdn.microsoft.com/en-us/library/ha0k3c9f(v=vs.110).aspx
The License Compiler reads text files that contain licensing
information and produces a binary file that can be embedded in a
common language runtime executable as a resource. A .licx text file is
automatically generated or updated by the Windows Forms Designer
whenever a licensed control is added to the form. As part of
compilation, the project system will transform the .licx text file
into a .licenses binary resource that provides support for .NET
control licensing. The binary resource will then be embedded in the
project output. Cross compilation between 32-bit and 64-bit is not
supported when you use the License Compiler when building your
project. This is because the License Compiler has to load assemblies,
and loading 64-bit assemblies from a 32-bit application is not
allowed, and vice versa. In this case, use the License Compiler from
the command line to compile the license manually, and specify the
corresponding architecture. This tool is automatically installed with
Visual Studio. To run the tool, use the Developer Command Prompt (or
the Visual Studio Command Prompt in Windows 7). For more information,
see Visual Studio Command Prompt.
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.