Publish error in Visual Studio
I keep getting this insane error which makes me think VS has gone stupid rather than wiser.
Error 1 Copying file Content\Images\Brands\Lenovo.png to obj\Debug\Package\PackageTmp\Content\Images\Brands\Lenovo.png failed. Could not find file 'Content\Images\Brands\Lenovo.png'. 0 0 PriceCompare
The error is produced when i try to publish to file system. It's stupid that VS is looking for a file which i deleted myself and it doesn't reside in the solution now.
Earlier too i was deleting and adding files but suddenly today the publish command has started giving errors.
In many of the other posts, i have seen people asking to open the .csproj file with notepad and remove the references to the deleted files manually. This seems very daunting as i have deleted a long list of files and added a lot of new ones.
Is there an easier way to get rid of this problem or i need to manually remove the references to deleted file. Can't i just delete the obj folder or empty the bin directory or clean solution or something.
You need to tell Visual Studio that you deleted the files.
Go to the project/solution folder where the files existed and remove them there.
Visual Studio assumes that since you added the file originally, it should be published. It can't assume that you don't want it just because it isn't in the filesystem. Think about using source control in a team - the file may only exist in one persons's machine, but still be needed.
This is not a difficult as you think - the files that can not be found have a semi-transparent look to them, easy enough to select these and bulk delete in Visual Studio. You can also set the project properties to display all files then select all the ones that need to be part of the project and add them in a single operation.
This basically happens whenever we delete the contents from the folder but forget to remove from Visual studio solutions.
To Resolve this follow below steps:-
- Go to visual studio solution explorer and right click on the specific content
- exclude from project.
- right click and remove from visual studio solution explorer.
Hoping this will help you :)
I ran into same issue because project files were added and removed so many times. Me just removed yellow marked file from visual studio solution & it worked fine for me.
In my case, Problem with access permissions, I run VS in Administrator mode(Run as Administrator). Did the Trick.
Shows this message when you delete a file but its name still remains in the project. Locate the file shown in the message. Then delete it.