question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected Internal Software Issue (EX_SOFTWARE) An item with the same key has already been added. Key: -p:R

See original GitHub issue

Updated VS, and got dotnet version 7.0.100. Now my (unchanged) template fails, with stacktrace below. Cannot trace the -p:R to any parameters passed to dotnet new.

An item with the same key has already been added. Key: -p:R at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) at System.CommandLine.Parsing.StringExtensions.ValidTokens(Command command) at System.CommandLine.Parsing.StringExtensions.Tokenize(IReadOnlyList1 args, CommandLineConfiguration configuration, Boolean inferRootCommand) at System.CommandLine.Parsing.Parser.Parse(IReadOnlyList1 arguments, String rawInput) at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.ReparseForTemplate(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup, CliTemplateInfo template, Boolean validateDefaultLanguage) at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.ReparseForTemplate(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup, IEnumerable1 templatesToReparse, Boolean& languageOptionSpecified) at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.GetTemplateCommand(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup) at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.HandleTemplateInstantationAsync(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup, CancellationToken cancellationToken) at Microsoft.TemplateEngine.Cli.Commands.InstantiateCommand.ExecuteIntAsync(InstantiateCommandArgs instantiateArgs, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, InvocationContext context) at Microsoft.TemplateEngine.Cli.Commands.BaseCommand1.InvokeAsync(InvocationContext context)

For details on the exit code, refer to https://aka.ms/templating-exit-codes#70

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JanKrivanekcommented, Nov 11, 2022

Minimal repro:

template.json:

{
  "$schema": "http://json.schemastore.org/template",
  "author": "dotnetnew",
  "classifications": [ "bug-repro" ], 
  "name": "Bug Repro",
  "identity": "bug-repro",         
  "groupIdentity":"bug-repro",
  "shortName": "bug-repro",                   
  "tags": { "type":"project" },
  "symbols": { 
	"Param1": {
		"type": "parameter",
	},
	"Param2": {
		"type": "parameter",
	},
	"Param3": {
		"type": "parameter",
	},
	"Param4": {
		"type": "parameter",
	}
  }
}

@mkonijnenburg, @satyajit-behera - thank you for reporting this issue and appology for the inconvenience caused. Issue is currently understood, fix is about to be submitted and it will be considered for the next servicing release.

In the meantime (before next servicing release) you have 2 options how to workaround this issue:

  1. Edit the template.json - Rename the symbols in a way so that there are no more than 3 symbols with the same prefix
  2. Add dotnetcli.host.json Add dotnetcli.host.json next to your template.json file and specify custom short aliases for your symbols, or turn them off alltogether. Sample dotnetcli.host.json for the minimal repro above:
{
  "$schema": "http://json.schemastore.org/dotnetcli.host",
  "symbolInfo": {
    "Param1": {
      "shortName": ""
    },
    "Param2": {
      "shortName": ""
    },
    "Param3": {
      "shortName": ""
    },
    "Param4": {
      "shortName": ""
    },
  }
}
0reactions
mkonijnenburgcommented, Nov 11, 2022

Thanks for the info and tip about the default value. I hope the fix will arrive shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An item with the same key has already been added
Solution is to override the property or use another name. If you share your model, we would be able to elaborate more. Share....
Read more >
Error "An item with the same key has already been added"
This article helps to fix the error "An item with the same key has already been added". Applies to: Windows Server 2012 R2...
Read more >
Getting error "An item with the same key has already been ...
We ran into the same issue and it seems to generally occur with the new project type. Repro is simple: Create a blank...
Read more >
An item with the same key has already been added Error
The error reads: "An item with the same key has already been added." It does not matter if I include the database name...
Read more >
'An item with the same key has already been added' error after ...
An error with message 'An item with the same key has already been added' is shown in the error logs after submitting a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found