我正在尝试运行ASP。NET MVC(模型-视图-控制器)项目从TFS (Team Foundation Server)源代码控制检索。我已经添加了所有程序集引用,我能够成功地构建和编译,没有任何错误或警告。

但是我在浏览器中得到以下错误:

找不到路径的一部分 “C: \ B8akWorkspace \ B8akProject \ B8akSolution \ B8AK.Portal \ bin \ roslyn \ csc.exe”。

以下是错误页面的完整截图。

经过几天的研究,我了解到Roslyn是一个提供高级编译特性的. net编译器平台。但是,我不明白为什么我的构建试图找到\bin\roslyn\csc.exe,因为我没有配置任何与roslyn相关的东西。我也没打算让罗斯林参与我的项目。


当前回答

我在服务器上安装应用程序时遇到了同样的问题,而在localhost上一切都很完美。

这些解决方案都不奏效,我总是犯同样的错误:

Could not find a part of the path 'C:\inetpub\wwwroot\myApp\bin\roslyn\csc.exe'

我最后是这样做的:

在我的安装项目中,右clic,查看>文件系统 创建一个bin/roslyn文件夹 选择添加>文件,并添加包\Microsoft.Net.Compilers.1.3.2\tools中的所有文件

这解决了我的问题。

其他回答

在我的情况下,我有问题在詹金斯,当它试图部署它在章鱼有以下错误:

MSBUILD : OctoPack error OCT-1676060969: Failed to build the path for '\bin\roslyn\csc.exe' relative to 'T:\workspace\machine.engine\Machine.engine.Test': Invalid URI: The format of the URI could not be determined.. See the inner exception for more details. [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
MSBUILD : OctoPack error OCT-1676060969: System.Exception: Failed to build the path for '\bin\roslyn\csc.exe' relative to 'T:\workspace\machine.engine\Machine.engine.Test': Invalid URI: The format of the URI could not be determined.. See the inner exception for more details. ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined. [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
MSBUILD : OctoPack error OCT-1676060969:    at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
MSBUILD : OctoPack error OCT-1676060969:    at System.Uri..ctor(String uriString) [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
MSBUILD : OctoPack error OCT-1676060969:    at OctoPack.Tasks.Util.OctopusPhysicalFileSystem.GetPathRelativeTo(String fullPath, String relativeTo) in Z:\buildAgent\workDir\20ba9f2e0d5e4022\source\OctoPack.Tasks\Util\OctopusPhysicalFileSystem.cs:line 211 [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
MSBUILD : OctoPack error OCT-1676060969:    --- End of inner exception stack trace --- [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
MSBUILD : OctoPack error OCT-1676060969:    at OctoPack.Tasks.Util.OctopusPhysicalFileSystem.GetPathRelativeTo(String fullPath, String relativeTo) in Z:\buildAgent\workDir\20ba9f2e0d5e4022\source\OctoPack.Tasks\Util\OctopusPhysicalFileSystem.cs:line 224 [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
MSBUILD : OctoPack error OCT-1676060969:    at OctoPack.Tasks.CreateOctoPackPackage.AddFiles(XContainer nuSpec, IEnumerable`1 sourceFiles, String sourceBaseDirectory, String targetDirectory, String relativeTo) in Z:\buildAgent\workDir\20ba9f2e0d5e4022\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 443 [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
MSBUILD : OctoPack error OCT-1676060969:    at OctoPack.Tasks.CreateOctoPackPackage.Execute() in Z:\buildAgent\workDir\20ba9f2e0d5e4022\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 190 [T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj]
Done Building Project "T:\workspace\machine.engine\Machine.engine.Test\Machine.engine.Test.csproj" (default targets) -- FAILED

导致

在花了一段时间后,我使用了一个内部开发的组件,该组件使用Microsoft.Net.Compilers。内部组件使用Microsoft.Net.Compilers的原因是为了克服这个问题(c#:抛出无效的表达式编译),并以这种方式解决(如何在Visual Studio 2015中使用c# 7 ?)这导致,当我在主程序上安装组件时,Microsoft.Net.Compilers会自动添加。

解决方案

我的工作是,卸载以下从我们的内部组件(以下@malikKhalil回答)

PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
PM> Uninstall-package Microsoft.Net.Compilers

并且在Jenkins中选择了c# 7编译器而不是c# 6和重建,这是为了确保一切都能正常工作和构建。

最后,在我的主程序中,我尝试更新我的内部组件。一切都比重新建造好。它没有任何问题或问题。

在我的情况下,我注意到“构建”文件夹不在“packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0”路径中。这就是为什么没有创建roslyn文件夹的原因。

所以我的解决方案是:

清洁解决方案 进入Nuget包管理器 卸载Microsoft.CodeDom.Providers.DotNetCompilerPlatform 清洁解决方案 从Nuget包管理器中重新安装Microsoft.CodeDom.Providers.DotNetCompilerPlatform。 清洁/重建

好了。以上的解决方案对我都不起作用。希望这对大家有所帮助

清洁解决方案 重建方案 这两步对我很管用。

很多答案都涉及到Nuget包和/或清理和重新加载你的项目。

如果您有WCF服务引用和无效端点,也可以得到此错误消息。确保您的端点是正确的,并在.config和从GUI配置服务引用时使用正确的端点更新服务配置。

默认的VS2015模板的问题是编译器实际上没有复制到tfr\bin\roslyn\目录中,而是复制到{outdir}\roslyn\目录中

在.csproj文件中添加以下代码:

<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>