This question already has an answer here:
Hello World in C++ using Visual Studio 2017 Thank you for downloading Visual Studio and start your first C++ journey! First, understand the layout and views once you launch Visual Studio 2017. For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 1 or Tutorial 1: Create a Picture Viewer in C# - Video 1. These videos use an earlier version of Visual Studio, so there are slight differences in some menu commands and other user interface elements.
- Compiling/Executing a C# Source File in Command Prompt 10 answers
I am very new to C#. I have just run C# 'Hello World' program using Visual Studio.
Can I run or compile a C# program without using Visual Studio?
If it is possible, then which compiler should I use?
Thanks
marked as duplicate by nawfal, Frank van Puffelen, karthik, greg-449, Mark RotteveelJul 23 '14 at 10:45
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
6 Answers
If you have .NET v4 installed (so if you have a newer windows or if you apply the windows updates)
or
or
It's highly probable that if you have .NET installed, the %FrameworkDir%
variable is set, so:
I use a batch script to compile and run C#:
I call it like this:
I also have a shortcut in Notepad++, which you can define by going to Run > Run...:
I assigned this shortcut to my F5 key for maximum laziness.
There are different ways for this:
1.Building C# Applications Using csc.exe
While it is true that you might never decide to build a large-scale application using nothing but the C# command-line compiler, it is important to understand the basics of how to compile your code files by hand.
2.Building .NET Applications Using Notepad++
Another simple text editor I’d like to quickly point out is the freely downloadable Notepad++ application.This tool can be obtained from http://notepad-plus.sourceforge.net. Unlike the primitive WindowsNotepad application, Notepad++ allows you to author code in a variety of languages and supports
3.Building .NET Applications Using SharpDevelop
As you might agree, authoring C# code with Notepad++ is a step in the right direction, compared toNotepad. However, these tools do not provide rich IntelliSense capabilities for C# code, designers forbuilding graphical user interfaces, project templates, or database manipulation utilities. To address suchneeds, allow me to introduce the next .NET development option: SharpDevelop (also known as'#Develop').You can download it from http://www.sharpdevelop.com.
You can use .NET sdk, or alternatively:
Online compiler doesn't offer much, but can be learning tool for simple homework-style tasks.
Another option is an interesting open source project called ScriptCS. It uses some crafty techniques to allow you a development experience outside of Visual Studio while still being able to leverage NuGet to manage your dependencies. It's free, very easy to install using Chocolatey. You can check it out here http://scriptcs.net.
Another cool feature it has is the REPL from the command line. Which allows you to do stuff like this:
You can create C# utility 'scripts' which can be anything from small system tasks, to unit tests, to full on Web APIs. In the latest release I believe they're also allowing for hosting the runtime in your own apps.
Check out it development on the GitHub page too https://github.com/scriptcs/scriptcs
If you have a project ready and just want to change some code and then build. Check out MSBuild which is located in the Microsoft.Net under windows directory.
Create A Visual Basic Program
C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild 'C:ProjectsMyProject.csproj' /p:Configuration=Debug;DeployOnBuild=True;PackageAsSingleFile=False;outdir=C:ProjectsMyProjectsPublish(Please do not edit, leave as a single line)
... The line above broken up for readability
C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild 'C:ProjectsMyProject.csproj'/p:Configuration=Debug;DeployOnBuild=True;PackageAsSingleFile=False;outdir=C:ProjectsMyProjectsPublish
Not the answer you're looking for? Browse other questions tagged c#visual-studiocompilation or ask your own question.
-->When you build source code, the build engine creates assemblies and executable applications. In general, the build process is very similar across many different project types such as Windows, ASP.NET, mobile apps, and others. The build process is also similar across programming languages such as C#, Visual Basic, C++, and F#.
By building your code often, you can quickly identify compile-time errors, such as incorrect syntax, misspelled keywords, and type mismatches. You can also detect and correct run-time errors, such as logic errors and semantic errors, by building and running debug versions of the code.
A successful build validates that the application's source code contains correct syntax and that all static references to libraries, assemblies, and other components can resolve. An application executable is produced that can be tested for proper functioning in both a debugging environment and through a variety of manual and automated tests to validate code quality. Once the application has been fully tested, you can compile a release version to deploy to your customers. For an introduction to this process, see Walkthrough: Building an application.
How To Run C Program In Visual Studio 2017
You can use any of the following methods to build an application: the Visual Studio IDE, the MSBuild command-line tools, and Azure Pipelines:
Build Method | Benefits |
---|---|
IDE | - Create builds immediately and test them in a debugger. - Run multi-processor builds for C++ and C# projects. - Customize different aspects of the build system. |
MSBuild command line | - Build projects without installing Visual Studio. - Run multi-processor builds for all project types. - Customize most areas of the build system. |
Azure Pipelines | - Automate your build process as part of a continuous integration/continuous delivery pipeline. - Apply automated tests with every build. - Employ virtually unlimited cloud-based resources for build processes. - Modify the build workflow and create build activities to perform deeply customized tasks. |
The documentation in this section goes into further details of the IDE-based build process. For more information on the other methods, see MSBuild and Azure Pipelines, respectively.
Note
This topic applies to Visual Studio on Windows. For Visual Studio for Mac, see Compile and build in Visual Studio for Mac.
Overview of building from the IDE
When you create a project, Visual Studio created default build configurations for the project and the solution that contains the project. These configurations define how the solutions and projects are built and deployed. Project configurations in particular are unique for a target platform (such as Windows or Linux) and build type (such as debug or release). You can edit these configurations however you like, and can also create your own configurations as needed.
For a first introduction to building within the IDE, see Walkthrough: Building an application.
Next, see Building and cleaning projects and solutions in Visual Studio to learn about the different aspects customizations you can make to the process. Customizations include changing output directories, specifying custom build events, managing project dependencies, managing build log files, and suppressing compiler warnings.
From there, you can explore a variety of other tasks:
- Manage project and solution properties.
- Specify build events in C# and Visual Basic.
- Build multiple projects in parallel.