我有一个F#伪脚本,它与Nuge.Core
一起使用来提取包文件。如果我尝试用c#控制台应用程序来做到这一切,一切正常。但是,如果我在f#伪脚本中执行完全相同的脚本,则它不起作用。这里有这么多的依赖关系,我不知道到哪里寻找帮助:docker.dotnet
,fake
,f#
,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#控制台应用程序
您确定在两种情况下都引用了相同版本的'NuGet'库吗? –
是的,在样品提供这不明确,但这是第一件要检查。此外,我已尝试过每个依赖项的多个版本。 – mynkow
您可以尝试用fsi.exe调用脚本吗?如果它适用于fsi而不适用于FAKE,那么您可能需要在FAKE github存储库上记录一个错误。谢谢! – smoothdeveloper