Docs: C# compiler options specifies web.config as the only place where compiler options are set

Created on 24 Jan 2018  Â·  8Comments  Â·  Source: dotnet/docs

This topic says "In Visual Studio, you set compiler options in the web.config file". Is that correct? I think this sentence is misleading as AFAIK web.config only exists for web applications.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Area - C# Guide Technology - C# / VB diagnostics P2 Pri2 doc-bug dotnet-csharprod

All 8 comments

@eduard-malakhov thanks for your feedback. Yes, that is incorrect. We'll investigate to see all options where you can set those.

@eduard-malakhov Thanks for reporting this. I'm investigating with the team about the history of that sentence, and what was meant by adding it. I'll add comments here once I've gotten those answers.

Closing this and using the new one.

@HongGit can we remove
In Visual Studio, you set compiler options in the web.config file

Ping. Any updates? I would like to know how C# compiler options can be set using the dotnet cli.

You should open up a new issue. This issue is about removing that line because it's not applicable for this article.

However, to quickly address your comment, I don't know that you can. .NET Core uses projects and MSBuild to control compiling, and you would have to explore how that works and how to customize (if you can, I don't know if you can) building specific files.

It looks like MSBuild does provide a task to invoke the compiler, I don't know if it works on .NET Core though, it may only be applicable to .NET Framework. https://docs.microsoft.com/en-us/visualstudio/msbuild/csc-task?view=vs-2019

Also, I found this via search: https://stackoverflow.com/questions/46065777/is-it-possible-to-compile-a-single-c-sharp-code-file-with-the-net-core-roslyn-c

Which indicates that you can explore the roslyn compiler included with the .NET Core SDK:

C:\Program Files\dotnet\sdk\{your-sdk-version}\Roslyn\bincore> dotnet .\csc.dll -help

Thanks @Thraka . In case anyone ran into the same issue: I was trying to set the /r compiler option for extern alias. I found a workaround at https://github.com/NuGet/Samples/issues/39.

Seems like a lot of time to remove a sentence...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FrancescoBonizzi picture FrancescoBonizzi  Â·  3Comments

LJ9999 picture LJ9999  Â·  3Comments

ite-klass picture ite-klass  Â·  3Comments

stjepan picture stjepan  Â·  3Comments

sebagomez picture sebagomez  Â·  3Comments