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

error MSB3105: The item "XXX.cs" was specified more than once in the "Sources" parameter. #604

Closed
galvesribeiro opened this issue Jan 9, 2017 · 17 comments

Comments

@galvesribeiro
Copy link
Member

While trying to build this PR dotnet/Docker.DotNet#144 for some reason it is thinking I have a duplicated file in the CI build at AppVeyor.

C:\Program Files\dotnet\sdk\1.0.0-preview5-004460\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB3105: The item "AnonymousCredentials.cs" was specified more than once in the "Sources" parameter.  Duplicate items are not supported by the "Sources" parameter. [C:\projects\docker-dotnet\Docker.DotNet\Docker.DotNet.csproj]

1.0.0-preview5-004232 build it just fine. However, the latest version 1.0.0-preview5-004460 throw this error for the same project...

Any ideas?

@eerhardt
Copy link
Member

eerhardt commented Jan 9, 2017

The latest SDK adds all .cs files by default now without any "Compile" lines.

To fix the error either:

  1. Remove all "Compile" elements from your .csproj and let the SDK add all .cs files to your project automatically. See https://github.com/dotnet/sdk/blob/master/src/Templates/ProjectTemplates/CSharp/.NETCore/CSharpConsoleApplication/ProjectTemplate.csproj for the latest .csproj console app template. Or https://github.com/dotnet/sdk/blob/master/src/Templates/ProjectTemplates/CSharp/.NETCore/CSharpClassLibrary/ProjectTemplate.csproj for the latest class library template for examples.
  2. If you want to control which files are added and don't want the SDK to automatically added them, set <EnableDefaultItems>false</EnableDefaultItems> property in your .csproj.

This experience will get better once #600 is fixed.

@galvesribeiro
Copy link
Member Author

AHHH, that is why :)

I would suggest have a repo only for announcements just like asp.net guys did so, whenever a breaking change happen on public API surface, they push an issue there. Its a readonly repo where everyone who is using latest release watch it for news.

Now I changed the AppVeyor script like this and the build work:

version: '2.124.2.{build}'
pull_requests:
  do_not_increment_build_number: true
init:
- ps: (new-object net.webclient).DownloadFile('https://dotnetcli.blob.core.windows.net/dotnet/Sdk/rel-1.0.0/dotnet-dev-win-x64.latest.exe', "c:/dotnet-install.exe")
- ps: Start-Process c:\dotnet-install.exe -ArgumentList "/install","/quiet" -Wait
build_script:
- ps: dotnet restore
- ps: dotnet build .\Docker.DotNet\Docker.DotNet.csproj -c Release
- ps: dotnet build .\Docker.DotNet.X509\Docker.DotNet.X509.csproj -c Release
- ps: dotnet build .\Docker.DotNet.BasicAuth\Docker.DotNet.BasicAuth.csproj -c Release

One caveat there. If I dotnet build at the solution level, the build now fail saying that Docker.DotNet.dll is being used by another process. I had to build every project isolated... Is that an issue with this release as well?

Thanks @eerhardt !

@galvesribeiro
Copy link
Member Author

@eerhardt more one problem detected... Even if dotnet build "works" as I stated, if you open in VS2017 the project here is what happen:

image

No files are loaded :(

@eerhardt
Copy link
Member

eerhardt commented Jan 9, 2017

I would suggest have a repo only for announcements just like asp.net guys did so, whenever a breaking change happen on public API surface, they push an issue there. Its a readonly repo where everyone who is using latest release watch it for news.

@srivatsn - thoughts?

If I dotnet build at the solution level, the build now fail saying that Docker.DotNet.dll is being used by another process. I had to build every project isolated... Is that an issue with this release as well?

That should work. @nguerrera @dsplaisted - any ideas why that would happen?

if you open in VS2017 the project here is what happen: No files are loaded :(

I assume that is because your install of VS2017 still has the old SDK, which doesn't automatically add the files. And since you removed them from your .csproj, when you load the project in VS2017, no one is adding the files.

@galvesribeiro
Copy link
Member Author

I assume that is because your install of VS2017 still has the old SDK, which doesn't automatically add the files. And since you removed them from your .csproj, when you load the project in VS2017, no one is adding the files.

@eerhardt I just added the SDK install from https://dotnetcli.blob.core.windows.net/dotnet/Sdk/rel-1.0.0/dotnet-dev-win-x64.latest.exe which is listed here https://github.com/dotnet/cli/#installers-and-binaries

How to update the one Visual Studio is using? It is very confusing that command line is using one thing and Visual Studio using other (and yes, I have no global.json at the solution)...

@galvesribeiro
Copy link
Member Author

BTW, the announcements repo for aspnet is this one: https://github.com/aspnet/Announcements

@describeme
Copy link

@galvesribeiro: hey, did u get around this?

How to update the one Visual Studio is using? It is very confusing that command line is using one thing and Visual Studio using other (and yes, I have no global.json at the solution)...

@eerhardt:
im also running preview5-004478 and even have it set in the global.json... but no *.cs files show up in the projects

@eerhardt
Copy link
Member

How to update the one Visual Studio is using? It is very confusing that command line is using one thing and Visual Studio using other (and yes, I have no global.json at the solution)...

@davkean @srivatsn - can someone help here? I don't know how to update the SDK that Visual Studio is using.

@galvesribeiro
Copy link
Member Author

@describeme nop, still same problem. I had to rollback the SDK unfortunately... I'm waiting for the MSFT guys to ping us back with a solution for it.

@srivatsn
Copy link
Contributor

The SDKs, currently, ship with VS itself. Acquisition\upgrade of newer SDKs has not been implemented yet. dotnet/msbuild#1493 tracks the design and the work to do that.

Until then, VS and CLI use their own SDKs. @galvesribeiro, you can set a property <EnableDefaultCompileItems>false</EnableDefaultCompileItems> and then the globs won't get added by default. That way VS will still see the files.

@galvesribeiro
Copy link
Member Author

@srivatsn ok, thanks for the reply! Will try that and report back. Thanks!

@srivatsn
Copy link
Contributor

We've now added a warning for this scenario. Closing this issue. Please reactivate if you're still running into problems.

@stevescot
Copy link

In my case this was a problem as the .csproj.user file had a reference in it as well as the .csproj - so have a look in both files - if it exists in both this can cause the problem

@ARMoir
Copy link

ARMoir commented Jun 2, 2018

Confirmed removing the Compile references from .csproj.user rather then .csproj resolved the issue keeping the .cs file available in Solution explorer.

@davkean
Copy link
Member

davkean commented Jun 3, 2018

@ARMoir @stevescot Do you have a repro of this?

@ARMoir
Copy link

ARMoir commented Jun 5, 2018

@davkean Not exactly, I opened my project and it would not load error 'One or more projects in the solution were not loaded correctly. Please see the Output Window for details. root element missing' I realized .csproj.user was .csproj.user.bak so I removed the .bak (something like that) then the project opened but I got the 'specified more than once in the "Sources" parameter' until I removed the 'Compile' references from .csproj.user

@SidShetye
Copy link

On linux this can happen when you have case duplicates e.g. folder/class.cs as well as Folder/class.cs. IMHO, the error message needs to capture this situation and give a more useful message to users.

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

8 participants