sdk icon indicating copy to clipboard operation
sdk copied to clipboard

An item with the same key has already been added. Key: Microsoft.DotNet.ProjectM odel.ProjectContextBuilder+LibraryKey

Open mikeandersun opened this issue 10 years ago • 6 comments

dotnetbuild produces this error : An item with the same key has already been added. Key: Microsoft.DotNet.ProjectM odel.ProjectContextBuilder+LibraryKey

mikeandersun avatar May 06 '16 18:05 mikeandersun

Hey @mikeandersun,

Please share following:

  • dotnet -v build output
  • dotnet --info output
  • some repro (project.json + Program.cs)
  • your OS information (if dotnet --info doesn't contain it)

krwq avatar May 06 '16 19:05 krwq

My OS : Windows 7 - 64bit dotnet -v output:

.NET Command Line Tools (1.0.0-beta-001598)
Usage: dotnet [common-options] [command] [arguments]

Arguments:
  [command]     The command to execute
  [arguments]   Arguments to pass to the command

Common Options (passed before the command):
  -v|--verbose  Enable verbose output
  --version     Display .NET CLI Version Info

Common Commands:
  new           Initialize a basic .NET project
  restore       Restore dependencies specified in the .NET project
  build         Builds a .NET project
  publish       Publishes a .NET project for deployment (including the runtime)
  run           Compiles and immediately executes a .NET project
  repl          Launch an interactive session (read, eval, print, loop)
  pack          Creates a NuGet package

dotnet --info output:

Unknown option: --info
.NET Command Line Tools (1.0.0-beta-001598)
Usage: dotnet [common-options] [command] [arguments]

Arguments:
  [command]     The command to execute
  [arguments]   Arguments to pass to the command

Common Options (passed before the command):
  -v|--verbose  Enable verbose output
  --version     Display .NET CLI Version Info

Common Commands:
  new           Initialize a basic .NET project
  restore       Restore dependencies specified in the .NET project
  build         Builds a .NET project
  publish       Publishes a .NET project for deployment (including the runtime)
  run           Compiles and immediately executes a .NET project
  repl          Launch an interactive session (read, eval, print, loop)
  pack          Creates a NuGet package

project.config

{
    "userSecretsId": "aspnet5-Lab-f9bb657f-a686-4755-b16e-caad6d43beb8",
    "version": "1.0.0-*",
    "webroot": "wwwroot",
    "tooling": {
        "defaultNamespace": "MyWeb"
    },
    "packOptions": {
        "summary": "This project is really great.",
        "tags": [ "tag1", "tag2" ],
        "owners": [ "My Name", "Your Name" ],
        "releaseNotes": "Did lots of great things in this release",
        "iconUrl": "https://example.com/an-icon.png",
        "projectUrl": "https://example.com",
        "licenseUrl": "https://example.com/license",
        "requireLicenseAcceptance": false,
        "repository": {
            "type": "git",
            "url": "https://github.com/exampleorg/example"
        },
        "files": {
            "include": "",
            "exclude": "",
            "includeFiles": [ "" ],
            "excludeFiles": [ "" ],
            "builtIns": { },
            "mappings": {
                "./dest/path": "./src/path"
            }
        }
    },
    "runtimeOptions": {
        "configProperties": {
            "System.GC.Server": true
        }
    },
    "buildOptions": {

        "compile": {
            "include": [ "" ],
            "exclude": [
                "../myweb.WebApp/Program.cs",
                "../myweb.WebApp/bin",
                "../myweb.WebApp/obj"
            ],
            "includeFiles": [ "" ],
            "excludeFiles": [ "" ],
            "builtIns": { },
            "mappings": {
                "./dest1": "./src1",
                "./dest2": [ "./src2" ]
            }
        },
        "embed": {
            "include": [ "" ],
            "exclude": [ "" ],
            "includeFiles": [ "" ],
            "excludeFiles": [ "" ],
            "builtIns": { },
            "mappings": {
                "./dest1": "./src1",
                "./dest2": [ "./src2" ]
            }
        },
        "copyToOutput": {
            "include": [
                "Views",
                "wwwroot",
                "appsettings.json",
                "web.config"
            ],
            "exclude": [ "" ],
            "includeFiles": [ "" ],
            "excludeFiles": [ "" ],
            "builtIns": { },
            "mappings": {
                "./dest/path1": "./src/path1",
                "./dest/path2": "./src/path2"
            }
        },

        "preserveCompilationContext": true,
        "emitEntryPoint": true,
        "debugType": "portable"
    },
    "publishOptions": {
        "include": [
            "Views",
            "wwwroot",
            "web.config"
        ],
        "exclude": [ ],
        "includeFiles": [ ],
        "excludeFiles": [

        ],
        "builtIns": [ ],
        "mappings": {
            "./dest/path": "./src/path"
        }

    },
    "dependencies": {
        "Microsoft.AspNetCore.Authentication": "1.0.0-*",
        "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*",
        "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*",
        "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*",
        "Microsoft.AspNetCore.Authorization": "1.0.0-*",
        "Microsoft.AspNetCore.Cors": "1.0.0-*",
        "Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
        "Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0-*",
        "Microsoft.AspNetCore.Http": "1.0.0-*",
        "Microsoft.AspNetCore.Http.Abstractions": "1.0.0-*",
        "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*",
        "Microsoft.AspNetCore.Mvc": "1.0.0-*",
        "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
        "Microsoft.AspNetCore.Session": "1.0.0-*",
        "Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
        "Microsoft.Extensions.Configuration": "1.0.0-*",
        "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*",
        "Microsoft.Extensions.Configuration.CommandLine": "1.0.0-*",
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*",
        "Microsoft.Extensions.Configuration.Json": "1.0.0-*",
        "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
        "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*",
        "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*",
        "Microsoft.Extensions.Logging.Console": "1.0.0-*",
        "Microsoft.Extensions.Options": "1.0.0-*",
        "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0-*",
        "Microsoft.NETCore.Platforms": "1.0.1-*",
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-*",
        "Newtonsoft.Json": "8.0.3",
        "System.IdentityModel.Tokens.Jwt": "5.0.0-*"


    },
    "exclude": [
        "wwwroot",
        "node_modules",
        "bower_components"
    ],
    "frameworks": {
        "net451": { },
        "netcoreapp1.0": {
            "dependencies": {
                "Microsoft.NETCore.App": {
                    "version": "1.0.0-*",
                    "type": "platform"
                }
            },
            "imports": [
                "dnxcore50",
                "portable-net451+win8"
            ]
        }
    },
    "tools": {

  },
    "scripts": {
        "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    },
        "runtimes": {
            "win7-x64": { },
            "win7-x86": { }
        }
    }

mikeandersun avatar May 06 '16 19:05 mikeandersun

@krwq I re-install last wervion on .NETCore SDK and the error go away. but this is a new error when i run dotnet run : Object reference not set to an instance of an object.

mikeandersun avatar May 06 '16 20:05 mikeandersun

@mikeandersun what --info produced that error?

TheRealPiotrP avatar May 06 '16 21:05 TheRealPiotrP

Use this command dotnet restore --no-cache

mfbasha avatar Jan 14 '17 20:01 mfbasha

I believe that this has been fixed in the latest tooling. Also, this is a project.json-specific bug. We don't have plans to ship additional project.json updates now that we've transitioned to msbuild. Closing the issue, therefore. Please reopen if you encounter the same error with the latest tooling.

thesmithee avatar Jan 19 '17 17:01 thesmithee