Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird error message when there where two targets with the same name #1375

Closed
wallymathieu opened this issue Sep 12, 2016 · 3 comments
Closed

Comments

@wallymathieu
Copy link
Member

Description

While writing a FAKE script I got a rather weird error message when there where two targets with the same name.

Repro steps

How did I get it wrong? Well I wrote the following:

Target "test" (fun _ -> // supposed to have been tests_only
    !! testAssemblies
    |> NUnit (fun p ->
        { p with
            DisableShadowCopy = true
            TimeOut = TimeSpan.FromMinutes 20.
            OutputFile = "TestResults.xml" })
)

Target "test" (fun _ -> ())

Expected behavior

I would have expected FAKE to report that target was already declared or something along those lines.

Actual behavior

This is the output I got:

No version specified. Downloading latest stable.
Paket.exe 3.19.3.0 is up to date.
Paket version 3.19.3.0
0 seconds - ready.
FsiEvaluationException:

Error: System.ArgumentException: An item with the same key has already been added.
      at System.ThrowHelper.ThrowArgumentException (System.ExceptionResource resource) [0x0000b] in <94fd79a3b7144c54b4cb162b50fc7761>:0 
      at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (TKey key, TValue value, System.Boolean add) [0x0008e] in <94fd79a3b7144c54b4cb162b50fc7761>:0 
      at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <94fd79a3b7144c54b4cb162b50fc7761>:0 
      at Fake.TargetHelper.targetFromTemplate[a] (Fake.TargetHelper+TargetTemplate`1[a] template, System.String name, a parameters) [0x00024] in <57cd19dfccf1c534a7450383df19cd57>:0 
      at Fake.TargetHelper.TargetTemplateWithDependencies[a] (Microsoft.FSharp.Collections.FSharpList`1[T] dependencies, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] body, System.String name, a parameters) [0x00017] in <57cd19dfccf1c534a7450383df19cd57>:0 
      at Fake.TargetHelper+TargetTemplate@254[a].Invoke (System.String name, a parameters) [0x00001] in <57cd19dfccf1c534a7450383df19cd57>:0 
      at Microsoft.FSharp.Core.FSharpFunc`2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg1, TResult arg2) [0x0000d] in <5584aad2904cf4daa7450383d2aa8455>:0 
      at <StartupCode$FSI_0005>.$FSI_0005_Build$fsx.main@ () [0x00091] in <760ff6be6b094913941f6a830312d643>:0 
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <94fd79a3b7144c54b4cb162b50fc7761>:0 
    Stopped due to error


Output: [Loading /Users/mathieu/src/LogAdapter/build.fsx]


Input: /Users/mathieu/src/LogAdapter/build.fsx

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] (Microsoft.FSharp.Core.FSharpChoice`2[T1,T2] res) [0x00030] in <5707a2f5ddab8ea7a7450383f5a20757>:0 
  at Microsoft.FSharp.Compiler.Interactive.Shell+FsiEvaluationSession.EvalScript (System.String filePath) [0x00014] in <5707a2f5ddab8ea7a7450383f5a20757>:0 
  at Yaaf.FSharp.Scripting.Helper+evalScript@1097.Invoke (System.String arg00) [0x00001] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Yaaf.FSharp.Scripting.Helper+saveScript@1090-1[a].Invoke (System.String path) [0x00033] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Yaaf.FSharp.Scripting.Helper+save_@1072-2[a].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00001] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Yaaf.FSharp.Scripting.Helper.consoleCapture[a] (System.IO.TextWriter out, System.IO.TextWriter err, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f) [0x0001a] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Yaaf.FSharp.Scripting.Helper.redirectOut@1044[a] (System.Boolean preventStdOut, Yaaf.FSharp.Scripting.Helper+OutStreamHelper out, Yaaf.FSharp.Scripting.Helper+OutStreamHelper err, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f) [0x0006e] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Yaaf.FSharp.Scripting.Helper+save_@1071-1[a].Invoke (System.String text) [0x0002c] in <57cd19dfccf1c534a7450383df19cd57>:0 
   --- End of inner exception stack trace ---
  at Yaaf.FSharp.Scripting.Helper+save_@1071-1[a].Invoke (System.String text) [0x0008e] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Yaaf.FSharp.Scripting.Helper+session@1100.Yaaf-FSharp-Scripting-IFsiSession-EvalScriptWithOutput (System.String ) [0x00001] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Fake.FSIHelper.runScriptUncached (System.Boolean useCache, System.String scriptPath, System.Collections.Generic.IEnumerable`1[T] fsiOptions, System.Boolean printDetails, Fake.FSIHelper+CacheInfo cacheInfo, System.IO.TextWriter out, System.IO.TextWriter err) [0x00187] in <57cd19dfccf1c534a7450383df19cd57>:0 
System.ArgumentException: An item with the same key has already been added.
  at System.ThrowHelper.ThrowArgumentException (System.ExceptionResource resource) [0x0000b] in <94fd79a3b7144c54b4cb162b50fc7761>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (TKey key, TValue value, System.Boolean add) [0x0008e] in <94fd79a3b7144c54b4cb162b50fc7761>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <94fd79a3b7144c54b4cb162b50fc7761>:0 
  at Fake.TargetHelper.targetFromTemplate[a] (Fake.TargetHelper+TargetTemplate`1[a] template, System.String name, a parameters) [0x00024] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Fake.TargetHelper.TargetTemplateWithDependencies[a] (Microsoft.FSharp.Collections.FSharpList`1[T] dependencies, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] body, System.String name, a parameters) [0x00017] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Fake.TargetHelper+TargetTemplate@254[a].Invoke (System.String name, a parameters) [0x00001] in <57cd19dfccf1c534a7450383df19cd57>:0 
  at Microsoft.FSharp.Core.FSharpFunc`2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg1, TResult arg2) [0x0000d] in <5584aad2904cf4daa7450383d2aa8455>:0 
  at <StartupCode$FSI_0005>.$FSI_0005_Build$fsx.main@ () [0x00091] in <760ff6be6b094913941f6a830312d643>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <94fd79a3b7144c54b4cb162b50fc7761>:0 
Stopped due to error

Related information

  • Operating system : OS X El Capitan
  • .NET Runtime: mono-4.6.0-branch/dea2155 Wed Sep 7 10:34:49 EDT 2016
@embix
Copy link

embix commented Mar 27, 2017

I second that. Just got the same error when we had the same target added in different branches. While the merge went fine without conflicts, the build (of course failed). Explicitly naming the task should make debugging such cases easier.

@forki
Copy link
Member

forki commented Mar 28, 2017 via email

@embix
Copy link

embix commented Mar 28, 2017

Bread and butter solution: just throw an exception and provide the name of the duplicate target. If there is a more sophisticated way of croaking in FAKE just give me a hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants