Could Not Find a Part of the Path ... Bin\Roslyn\Csc.Exe

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>

Could not find file ... bin\roslyn\csc.exe'

As you already mention,
the quick fix is to use the package manager,
Tools > Nuget Package Manager > Package Manager Console, to run

Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r

as pointed out by
https://stackoverflow.com/questions/32780315#34391473

Packet Manager Console - how to open

But an alternative solution (which I consider to be more robust) is to remove an attribute of your project's Web.config file.
(Web.config is in the same directory as your .csproj file.)

Open the Web.config file in a text editor (or inside Visual Studio).

- In the tag configuration | system.codedom | compilers | compiler language="c#;cs;csharp", completely remove the type attribute.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- ... -->
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>

In short, remove the line that starts with type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.

(Presumably, the same fix works for Visual Basic as well as for Csharp, but I have not tried it.)

Visual Studio will take care of the rest. No more Server Error in '/' Application.

In the example code I provided in the zip file above you will now get HTTP Error 403
when you hit Ctrl+F5.

HTTP Error 403.14 - Forbidden

Try replacing http://localhost:64195 in your web browser with http://localhost:64195/api/products.

The web API now displays as it should:

A web API containing products

As a provocation, I even tried removing the whole package directory of my Visual Studio solution.

It was automatically and silently recreated as soon as I (re-)built it.

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>

Publish: Could not find a part of the path … \obj\DEV\AspnetCompileMerge\Source\bin\roslyn\csc.exe'

This was a known issue whereby the Roslyn binary wasn't being copied correctly to the publish directory. It should be fixed if you install Microsoft.CodeDom.Providers.DotNetCompilerPlatform 1.0.7.

There seem to be some residual issues which are being tracked here.

Folder not found error even though the folder exists in c#

Thanks to this Post, I found a solution. The path I stated, "Phone storage/DCIM/Camera" was a simplification done by my phone's gallery and the correct technical path should be "/storage/emulated/0/DCIM/Camera".
Also, the technically correct path for the sd-card is:
"/sdcard/DCIM/Camera"
If I use this code it says that the folder exists :)



Related Topics



Leave a reply



Submit