csc

How can I target a specific language version using CodeDOM?

久未见 提交于 2019-11-30 08:44:27
Using the C# code provider and the ICodeCompiler.CompileAssemblyFromSource method, I am attempting to compile a code file in order to produce an executable assembly. The code that I would like to compile makes use of features such as optional parameters and extension methods that are only available when using the language C# 4. Having said that, the code that I would like to compile only requires (and needs ) to target version 2.0 of the .NET Framework. Using the proceeding code it is possible to avoid any compile-time errors pertaining to syntax however, the resulting assembly will target

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

☆樱花仙子☆ 提交于 2019-11-30 03:44:46
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 compile source code files without having a project (and listing referenced dependencies on the same command line)? On Linux, when I have the old csc and the new .NET Core installed, I get these timings: [root@li1742-80 test]# time dotnet build Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core Copyright (C) Microsoft Corporation. All

Is compiling Release and Debug going to generate different IL code + different machine code?

不打扰是莪最后的温柔 提交于 2019-11-30 03:03:49
问题 I heard compiling in Release mode generates optimized code than in Debug mode, which is fine. But is this optimization in the IL? is it in the machine code once the CLR runs it? is the metadata structure different from PE compiled in Release and Debug? thanks 回答1: Building in Release build turns on the /optimize compile option for the C# compiler. That has a few side-effects, the IL indeed changes but not a great deal. Notable is that the compiler no longer makes an effort to make the code

Why is csc.exe crashing when I last left the output encoding as UTF8?

Deadly 提交于 2019-11-29 14:46:21
I am having am having or have run into a very strange thing. I wonder if others have and why it's happening. Having run a one line program with this line System.Console.WriteLine(System.Console.OutputEncoding.EncodingName); I see the Encoding is Western European (DOS) Fine Here is a list of some codepages 1200 Unicode and 65001 utf-8 and Windows-1252 Western European (Windows) and 850 Western European DOS from https://msdn.microsoft.com/en-us/library/system.text.encoding(v=vs.110).aspx Say I write a C sharp program to change the encoding to utf-8 class sdf { static void Main(string[] args) {

Visual Studio gone bonkers: 'The directory name is invalid' error when trying to compile

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 13:55:57
问题 For some very odd reason, my Visual Studio 2008, when trying to compile a C# project, tries to write the output of the executable to a directory with the same name as an executable, at least it seems that that's what the error message implies. After running Compile on any of my projects, CSC.EXE reports the following compiler error: Could not write to output file 'D:\Projects\Examples\StringBuilderVsString\obj\Release\StringBuilderVsString.exe' -- 'The directory name is invalid. ' When I look

How can I target a specific language version using CodeDOM?

自闭症网瘾萝莉.ら 提交于 2019-11-29 11:52:28
问题 Using the C# code provider and the ICodeCompiler.CompileAssemblyFromSource method, I am attempting to compile a code file in order to produce an executable assembly. The code that I would like to compile makes use of features such as optional parameters and extension methods that are only available when using the language C# 4. Having said that, the code that I would like to compile only requires (and needs ) to target version 2.0 of the .NET Framework. Using the proceeding code it is

How to use references when compiling c# code via command line

跟風遠走 提交于 2019-11-29 04:49:45
Could anyone help me compile via command line some c# files? I have 4 files to compile, Main, Form1 (which uses 2.cs file) and another class used in the project. I would like to compile this project in command line so I could add the /t:library switch (like in this tutorial: http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx ). However after using "csc /t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs" I get missing assembly reference errros such as these: \Project\FaceRecProOVaspVer\FaceRecProOV\MainForm.cs(14,15): error CS0234: The

How to Compile C# with Specific Language Version

℡╲_俬逩灬. 提交于 2019-11-29 02:56:18
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 List<Action>(); foreach (var fruit in fruits) { actions.Add(() => Console.WriteLine(fruit)); } foreach(var a in actions) { a(); } } But no matter how I compile it, it always works as it does in 5.0 * . I've tried setting the language version in the csproj file (Build -> Advanced -> Language Version) and I've tried just building it on the command line: csc myProgram.cs

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

若如初见. 提交于 2019-11-29 00:10:02
问题 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 compile source code files without having a project (and listing referenced dependencies on the same command line)? On Linux, when I have the old csc and the new .NET Core installed, I get these timings: [root@li1742-80 test]# time dotnet build

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

徘徊边缘 提交于 2019-11-28 22:44:09
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 to display this information? acfrancis When you build a project or solution in Visual Studio, the entire command line used to run the compiler (csc.exe, including switches and parameters) is displayed in the Output window. If you don't see it there, check the Verbosity level by going to: Options > Projects and Solutions > Build and Run > MSBuild