Questions tagged [csc]

Csc.exe is the command-line compiler for C# from Microsoft.

Csc.exe is the command-line compiler for C# from Microsoft.

301 questions
77
votes
11 answers

Is it possible to install a C# compiler without Visual Studio?

I want to build projects from the command line. Is it possible to deploy a C# compiler without installing Visual Studio?
Pavel Bastov
  • 6,911
  • 7
  • 39
  • 48
73
votes
5 answers

Is it possible to compile a single C# code file with the .NET Core Roslyn compiler?

In old .NET we used to be able to run the csc compiler to compile a single .cs file or several files. With .NET Core we have dotnet build that insists on having a proper project file. Is there a stand-alone command line compiler that would allow to…
Andrew Savinykh
  • 25,351
  • 17
  • 103
  • 158
73
votes
3 answers

Is there a way to get the build command line used by Visual Studio?

I want to do a build from the command line, but I'd like to get the exact command line syntax from Visual Studio (2012), so that I don't have to manually figure out all of the flags, imports, and other parameters. Is there a way to get Visual Studio…
Joshua Frank
  • 13,120
  • 11
  • 46
  • 95
71
votes
10 answers

How to get csc.exe path?

Is there a way to get path for the latest .NET Framework's csc.exe? The file usually in: c:\Windows\Microsoft.NET\Framework\vX.X.XXX but the problem is there can be multiple versions installed + there are both 32 and 64 bit versions. Any solution to…
Rok Povsic
  • 4,626
  • 5
  • 37
  • 53
54
votes
1 answer

Idempotent modifiers in C#

I noticed that if I write something like: static void Main(string[] args) { const const const bool flag = true; } The compiler doesn't warn me of the multiple consts. So this seems to mimic C modifiers, as they are idempotent. However, if I…
xdevel2000
  • 20,780
  • 41
  • 129
  • 196
52
votes
1 answer

For what reason would I choose a C# compiler file alignment setting other than 512?

I can see in MS Docs how to change the file alignment for C# compilation (via project settings and the command line). I have googled and seen articles explaining that a file alignment of 512 Bytes reduces the size of the .dll. I have tested myself…
J M
  • 1,877
  • 2
  • 20
  • 32
47
votes
12 answers

Why does C# encounter this error as to the CSC file?

I am pretty new in C# development and I have the following problem. When I try to build the application on which I am working I obtain the followings errors message: Error 2 Source file 'Log\LogUserManager.cs' could not be found …
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
33
votes
1 answer

'csc' is not recognized as an internal or external command, operable program or batch file

I'm fairly new to C# and I'm trying to use cmd to compile a basic hello world file called test.cs. It contains the following: // Similar to #include in C++, includes system namespaces in a program using System; using…
Callat
  • 2,928
  • 5
  • 30
  • 47
29
votes
4 answers

MSBUILD / csc: Cleanest way of handling x64 mscorlib warning 1607

I'm trying to use VS08SP1's default project system to invoke a C# compile in explicit x64 mode (as distinct from AnyCpu). When I explicitly mark a module as x64, I get a: warning CS1607: Assembly generation -- Referenced assembly 'mscorlib.dll'…
Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
28
votes
3 answers

PDB file larger on the second compile and then stays the same size

Using the following simple file: using System; public class Program{ [STAThread] public static void Main(string[] args){ Console.WriteLine("Boo"); } } And then using the following command: csc /target:exe…
REA_ANDREW
  • 10,666
  • 8
  • 48
  • 71
27
votes
1 answer

How to Compile C# with Specific Language Version

Let's say I want to demo to someone about the differences between foreach in C# 4.0 and 5.0. So I write up my code snippet: public static void Main() { string[] fruits = { "Apple", "Banana", "Cantelope" }; var actions = new…
Pharylon
  • 9,796
  • 3
  • 35
  • 59
26
votes
2 answers

Why does the C# compiler crash on this code?

Why does the code below crash the .NET compiler? It was tested on csc.exe version 4.0. See e.g. here for online demo on different version - it crashes in the same manner while it says dynamic is not supported…
Franta
  • 524
  • 5
  • 13
18
votes
1 answer

C# compiler bug or normal COM oddity?

C# 4, to simplify COM interop, allow callers to COM interfaces to omit the ref keyword in front of arguments for by ref parameters. I was surprised to see today that this also applies to extension methods that are extending COM interfaces. See the…
Jb Evain
  • 17,319
  • 2
  • 67
  • 67
18
votes
4 answers

Is there any FREE custom search api like google custom search?

I'm using google JSON/Atom Custom Search API now. The problem is the total queries are only 100 per day. Need to pay for extra queries. Is there any FREE Custom Search API? Maybe from Bing or Yahoo? Thanks!
user503853
18
votes
1 answer

Replacing c# compiler with new Roslyn build

I'm playing around with some changes to Roslyn, but unfortunately, even the unmodified solution would crash when I run VisualStudioSetup.Next, with an error trying to load an MS assembly. So I made some simple changes and replaced my machine's…
0_______0
  • 547
  • 3
  • 11
1
2 3
20 21