从System.Diagnostics.Process运行时,dotnet运行失败

时间:2017-06-12 13:36:13

标签: macos process f#

所以我确定我做了一些愚蠢的错事。我不确定它是什么。

如果我从终端运行以下命令,一切正常。

~>dotnet run --project /path/to/my.fsproj

但是,当我使用以下代码从fsx文件运行该命令时,我收到错误。

let dotnetRunNoArgs path =
    let info = ProcessStartInfo(FileName = "dotnet", Arguments = sprintf "run --project %s " path )
    let proc = new System.Diagnostics.Process(StartInfo = info)
    start proc
    proc

let buildProcessStartInfoFCollectionTests = 
    dotnetRunNoArgs "/path/to/my.fsproj"

buildProcessStartInfoFCollectionTests.Start() |> ignore

错误:

/Users/username/.nuget/packages/fsharp.net.sdk/1.0.0/build/FSharp.NET.Core.Sdk.targets(122,9): 
error MSB4062: The "Fsc" task could not be loaded from the assembly 
/Users/username/.nuget/packages/fsharp.compiler.tools/4.1.0/build/netcoreapp1.0/FSharp.Build.dll. 
Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [/path/to/my.fsproj] 
/Users/username/.nuget/packages/fsharp.net.sdk/1.0.0/build/FSharp.NET.Core.Sdk.targets(122,9): 
error MSB4062: The "Fsc" task could not be loaded from the assembly 
/Users/username/.nuget/packages/fsharp.compiler.tools/4.1.0/build/netcoreapp1.0/FSharp.Build.dll. 
Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [/path/to/my.fsproj]

The build failed. Please fix the build errors and run again.

1 个答案:

答案 0 :(得分:1)

错误最终出现在fsproj文件中。

问题是它需要在

上有版本属性
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0"/>

另外,我需要从项目代码中删除xmlns="http://schemas.microsoft.com/developer/msbuild/2003"

相关问题