2016-11-22 72 views
5

我有一个F#伪脚本,它与Nuge.Core一起使用来提取包文件。如果我尝试用c#控制台应用程序来做到这一切,一切正常。但是,如果我在f#伪脚本中执行完全相同的脚本,则它不起作用。这里有这么多的依赖关系,我不知道到哪里寻找帮助:docker.dotnetfakef#nuget.core在f#脚本中执行c#代码有意外的行为

要重现这一点,你需要下载Docker.DotNet.2.124.3.nupkg


您需要的C#示例控制台应用程序并安装nuget.core nuget软件包。这工作!

class Program 
{ 
    static void Main() 
    { 
     var zip = new NuGet.ZipPackage(@"Docker.DotNet.2.124.3.nupkg"); 
     foreach (var file in zip.GetFiles()) 
     { 
      System.Console.WriteLine(file.Path); 
     } 
    } 
} 

为F#示例你并排需要这两个文件的一面: https://gist.github.com/mynkow/e6f0e550fcacc268dd1e9b743e17d344

错误:

============================================================================== 
FsiEvaluationException: 

Error: System.InvalidOperationException: 'NETStandard.Library' already has a dependency defined for 'Microsoft.NETCore.Platforms'. 
      at NuGet.Manifest.ValidateDependencySets(IPackageMetadata metadata) 
      at NuGet.Manifest.Validate(Manifest manifest) 
      at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema) 
      at NuGet.LocalPackage.ReadManifest(Stream manifestStream) 
      at NuGet.ZipPackage.EnsureManifest(Func`1 manifestStreamFactory) 
      at NuGet.ZipPackage..ctor(String filePath, Boolean enableCaching) 
      at <StartupCode$FSI_0005>[email protected]() in C:\Users\mynkow\Desktop\Reproduce\test.fsx:line 12 
     Stopped due to error 


Output: [Loading C:\Users\mynkow\Desktop\Reproduce\test.fsx] 
     ============================================================================== 


Input: C:\Users\mynkow\Desktop\Reproduce\test.fsx 
\Arguments: 
    C:\fsi.exe 

Exception: Yaaf.FSharp.Scripting.FsiEvaluationException: Error while compiling or executing fsharp snippet. ---> System.Exception: Operation failed. The error text has been print the error stream. To return the corresponding FSharpErrorInfo use the EvalInteractionNonThrowing, EvalScriptNonThrowing or EvalExpressionNonThrowing 
    at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.commitResult[a,b](FSharpChoice`2 res) 
    at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.EvalScript(String filePath) 
    at [email protected](String arg00) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1303 
    at [email protected](Unit unitVar0) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1277 
    at Yaaf.FSharp.Scripting.Helper.consoleCapture[a](TextWriter out, TextWriter err, FSharpFunc`2 f) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1221 
    at [email protected][a](Boolean preventStdOut, OutStreamHelper out, OutStreamHelper err, FSharpFunc`2 f) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1254 
    at [email protected](String text) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1276 
    --- End of inner exception stack trace --- 
    at [email protected](String text) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1284 
    at [email protected]IFsiSession-EvalScriptWithOutput(String) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1308 
    at Fake.FSIHelper.runScriptUncached(Boolean useCache, String scriptPath, IEnumerable`1 fsiOptions, Boolean printDetails, CacheInfo cacheInfo, TextWriter out, TextWriter err) in C:\code\FAKE\src\app\FakeLib\FSIHelper.fs:line 471 
System.InvalidOperationException: 'NETStandard.Library' already has a dependency defined for 'Microsoft.NETCore.Platforms'. 
    at NuGet.Manifest.ValidateDependencySets(IPackageMetadata metadata) 
    at NuGet.Manifest.Validate(Manifest manifest) 
    at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema) 
    at NuGet.LocalPackage.ReadManifest(Stream manifestStream) 
    at NuGet.ZipPackage.EnsureManifest(Func`1 manifestStreamFactory) 
    at NuGet.ZipPackage..ctor(String filePath, Boolean enableCaching) 
    at <StartupCode$FSI_0005>[email protected]() in C:\Users\mynkow\Desktop\Reproduce\test.fsx:line 12 
Stopped due to error 

我与所有可能的依赖性的5个最新版本的尝试并且结果完全相同=> c#正在工作,f#不是。你有任何线索或任何你可以建议我试图解决这个问题吗?


肮脏的解决方案:
这是Docker.DotNet.2.124.3.nupkg怎么看起来像inside
如果我删除例如netstandard1.6一切正常。这意味着问题在nuget.core,对不对?但为什么它在C#控制台应用程序中工作?不知道!


UPDATE:我能够从F#控制台应用程序

+0

您确定在两种情况下都引用了相同版本的'NuGet'库吗? –

+0

是的,在样品提供这不明确,但这是第一件要检查。此外,我已尝试过每个依赖项的多个版本。 – mynkow

+0

您可以尝试用fsi.exe调用脚本吗?如果它适用于fsi而不适用于FAKE,那么您可能需要在FAKE github存储库上记录一个错误。谢谢! – smoothdeveloper

回答

1

我已经下载了一揽子贷款项目包正确执行的代码,改剧本是这样的:

#r @"./packages/FAKE/tools/FakeLib.dll" 
#r @"./packages/NuGet.Core/lib/net40-Client/NuGet.Core.dll" 

open System 
open System.Collections.Generic 
open System.IO 
open Fake 

Target "Test" (fun _ -> 
    printfn "==============================================================================" 
    global.NuGet.ZipPackage(@"Docker.DotNet.2.124.3.nupkg").GetFiles() |> Seq.iter(fun x -> printfn "%s" x.Path) 
) 

RunParameterTargetOrDefault "target" "test" 

它给这

Microsoft (R) F# Interactive version 14.0.23413.0 
Copyright (c) Microsoft Corporation. All Rights Reserved. 

For help type #help;; 

> 

--> Referenced 'C:\tmp\visualfsharp.issue.nuget\./packages/FAKE/tools/FakeLib.dll' 


--> Referenced 'C:\tmp\visualfsharp.issue.nuget\./packages/NuGet.Core/lib/net40-Client/NuGet.Core.dll' 

Building project with version: LocalBuild 
Shortened DependencyGraph for Target Test: 
<== Test 

The resulting target order is: 
- Test 
Starting Target: Test 
============================================================================== 
Running build failed. 
Error: 
System.InvalidOperationException: The schema version of 'Docker.DotNet' is incompatible with version 1.6.30117.9648 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942. 
    at NuGet.Manifest.CheckSchemaVersion(XDocument document) 
    at NuGet.Manifest.ValidateManifestSchema(XDocument document, String schemaNamespace) 
    at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider) 
    at NuGet.ZipPackage.EnsureManifest() 
    at [email protected](Unit _arg1) in C:\tmp\visualfsharp.issue.nuget\test.fsx:line 11 
    at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\FAKE\src\app\FakeLib\TargetHelper.fs:line 493 

--------------------------------------------------------------------- 
Build Time Report 
No target was successfully completed 
--------------------------------------------------------------------- 
--------------------------------------------------------------------- 

val it : unit =() 

> 

NuGet.Core的版本是2.12,我看到它是参考Mi未加载的crosoft.Web.Xdt。

也许你可以通过简单地使用paket并添加Docker.DotNet作为依赖来实现你想要的,它会为你提取它。

如果您有可复制的错误,请进行压缩并将问题发送到visualfsharp存储库。

+1

+1试图重现。我已经按照你的建议发布了一个问题。你可以在这里找到zip => https://github.com/Microsoft/visualfsharp/issues/1824 – mynkow