VS2017: CSC : warning CS2002: Source file <filename> specified multiple times. How to fix?
Asked Answered
Y

2

9

I just downloaded the new Visual Studio 2017 RTM and am using it to compile a Windows Library. I used VS2017 to create the new Windows Library project, then I copied into the folder all my code files and used VS to include them in the project. I added some necessary nuget packages and then compiled it.

I received the following warnings but he compile completed successfully.

 1>------ Rebuild All started: Project: MP_Prim, Configuration: Debug Any CPU ------
 1>CSC : warning CS2002: Source file 'obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs' specified multiple times
 1>CSC : warning CS2002: Source file 'obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs' specified multiple times
 1>CSC : warning CS2002: Source file 'obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs' specified multiple times
 1>  MP_Prim -> c:\users\ron clabo\documents\visual studio 2017\Projects\wwwGiftOasisResponsive\MP_Prim\bin\Debug\MP_Prim.dll
 ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

I'd like to make these warning go away. I researched the warning online but the info I found wasn't very helpful. The help amounted to "Remove redundant file specifiers." I could have guessed that myself based on the error.

But where is the redundant source file being specified? And based on the file name in the warning it's an auto generated file, so why is this auto generated file being fed to the compiler multiple times? And where is that being specified. In short, how can I fix this and make the warning away?

Yearling answered 9/3, 2017 at 15:39 Comment(1)
If nothing else and it's probably a bug, you can try the flag icon to report a problem. It was just released, so those are being monitored pretty well right now.Wanting
R
13

I don't know if you solved it yet, but I had the same error.

I just went to the obj/Debug folder right click and select Exclude from Project

That worked just fine for me. I didn't want to simply delete the files because I don't know what they are.

Rapscallion answered 6/4, 2017 at 14:7 Comment(1)
That's what I had to do also - Exclude. B/c if you delete it actually removes it form the HDD, and then the one remaining does not map to an actual file as the file-subsystem deleted the file.Outofdoor
M
1

I handled the message "Source file '...' specified multiple times" by select the Xxx Shared project, click the "Show All Files" icon-button go to the folder of the "Xxx.projitems" file and open it (in notepad++) and finally remove lines of files that appears multiple times.

Malaya answered 24/11, 2023 at 23:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.