Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building C# console project without Visual Studio

Tags:

c#

I need to create a script that produces an executable from a C# console project.

The client system where the script will be run doesn't have Visual Studio, but it has the .NET framework installed. How can it be done using a minimum or no software installation at the client place?

Does the C# compiler (csc.exe) come with .NET framework? If so, is there an environment variable for the location?

like image 759
softwarematter Avatar asked Sep 14 '11 06:09

softwarematter


2 Answers

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 folder under the Windows directory.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "C:\Projects\MyProject.csproj" /p:Configuration=Debug;DeployOnBuild=True;PackageAsSingleFile=False;outdir=C:\Projects\MyProjects\Publish\

(Please do not edit, leave as a single line)

... The line above broken up for readability

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "C:\Projects\MyProject.csproj"
/p:Configuration=Debug;DeployOnBuild=True;PackageAsSingleFile=False;
outdir=C:\Projects\MyProjects\Publish\

How to determine which versions and service pack levels of the Microsoft .NET Framework are installed

like image 159
Valamas Avatar answered Oct 23 '22 00:10

Valamas


If you're a Grandma, this is easily:

1

-- Create a .bat file with this:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe csharp.cs
csharp.exe

2

-- Create a .cs file with this:

class Program
{
    public static void Main()
        {
            System.Console.Clear();

            //code...

            System.Console.WriteLine("Congratulation! =D");

            //...code

            System.Console.ReadKey();
        }
}

and run .bat file =)

like image 26
Bendegúz Avatar answered Oct 23 '22 00:10

Bendegúz