2017-06-12 6 views
2

ausgeführt wird Ich bin mir sicher, dass ich etwas Dummes falsch mache. Ich bin mir nicht sicher, was es ist.dotnet run schlägt fehl, wenn es von System.Diagnostics.Process

Wenn ich den folgenden Befehl vom Terminal ausführen, funktioniert alles gut.

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

Allerdings, wenn ich diesen Befehl von einer FSX-Datei mit dem folgenden Code ausführen, bekomme ich einen Fehler.

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 

Fehler:

/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. 
+0

Vielleicht müssen Sie zuerst das ['CurrentDirectory'] (https://msdn.microsoft.com/en-us/library/system.environment.currentdirectory (v = vs.110) .aspx) zuerst festlegen? – kvb

+0

Unter Windows hatte ich Probleme, einige Programme direkt als Prozesse auszuführen. Ich musste stattdessen "cmd" starten und die eigentliche ausführbare Datei als Argument übergeben. Ich bin mir nicht sicher, ob das irgendeine Hilfe ist! – TheQuickBrownFox

+0

@TheQuickBrownFox dies ist eine OS X-Umgebung –

Antwort

1

Der Fehler ist in der fsproj Datei gelandet.

Das Problem war, dass es benötigte Version auf

<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" /> 
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0"/> 
Attribute auch

hat, ich xmlns="http://schemas.microsoft.com/developer/msbuild/2003" aus dem Projekt-Tag entfernen benötigt.

Verwandte Themen