Where to find csc.exe in .NET Framework 4.5?
CSC present in 4.0 folder (C:\Windows\Microsoft.NET\Framework64\v4.0.30319) is also csc of 4.5.
Path C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe is for 64 bit version of framework.
Could not find a part of the path ... bin\roslyn\csc.exe
The problem with the default VS2015 templates is that the compiler isn't actually copied to the tfr\bin\roslyn\
directory, but rather the {outdir}\roslyn\
directory
Add this code in your .csproj file:
<Target Name="CopyRoslynFiles" AfterTargets="AfterBuild" Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'">
<ItemGroup>
<RoslynFiles Include="$(CscToolPath)\*" />
</ItemGroup>
<MakeDir Directories="$(WebProjectOutputDir)\bin\roslyn" />
<Copy SourceFiles="@(RoslynFiles)" DestinationFolder="$(WebProjectOutputDir)\bin\roslyn" SkipUnchangedFiles="true" Retries="$(CopyRetryCount)" RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
</Target>
csc' is not recognized as an internal or external command, operable program or batch file
Locate the path of csc.exe and add it your PATH
environment variable.
In my case, the path for 64-bit C# compiler is C:\Windows\Microsoft.NET\Framework64\v4.0.30319
.
Similarly, you can look for 32-bit C# compiler in C:\Windows\Microsoft.NET\Framework
under different .NET framework version directories
There will be csc.exe for all versions like v2.0.XXXXX and v3.5. Select the one with the highest version in Framework64/Framework directory depending on your requirement.
Copy the path of csc.exe and add it to the PATH system environment variable.
Quit the cmd, and then launch again and run the program. That'd work.
How can I determine the path to the C# compiler?
Is there any reason you want to invoke the binary directly, instead of using CSharpCodeProvider
to programmatically compile?
You may be interested in my own snippet compiler (Snippy), which you can download the source for on my C# in Depth site.
Where on Earth is csc.exe?
It is in C:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
.
Of course, the path will be different for different framework versions.
Related Topics
Find If Point Lies on Line Segment
Authentication with Old Password No Longer Supported, Use 4.1 Style Passwords
Update Requires a Valid Updatecommand When Passed Datarow Collection with Modified Rows
The Operation Cannot Be Completed Because the Dbcontext Has Been Disposed Using MVC 4
How to Use C# 8 with Visual Studio 2017
Route Parameter with Slash "/" in Url
How to Access Gmail API Using Service Account
How to Check How Many Messages Are in a Msmq Queue
Multiple Identities in ASP.NET Core 2.0
Taking Screenshot of a Webpage Programmatically
The Remote Server Returned an Unexpected Response: (413) Request Entity Too Large
Print HTML Document from Windows Service Without Print Dialog
How to Disable the Horizontal Scrollbar in a Panel