Ray K.
Ray K.

Reputation: 2511

ASP.NET publish trying to copy a non-existant file

I'm trying to publish an ASP.NET project in VS2010, and am getting the following error:

Copying file bin\CKFinder.pdb to obj\Release\Package\PackageTmp\bin\CKFinder.pdb failed. Could not find file 'bin\CKFinder.pdb'.

I had tried using a trial version of CKFinder (with CKEditor), but I backed it out. I removed all references to CKFinder, including the folders and the references - or so I thought.

Why is this error coming up? Ideas?

Upvotes: 43

Views: 63521

Answers (13)

amir mohammad bayat
amir mohammad bayat

Reputation: 1

These problems occur when the bin file is included in the project, note that if the bin folder exists in your solution, exclude it.

Upvotes: 0

Alexander Benny
Alexander Benny

Reputation: 31

You must exclude bin folder from project, then republish your project. the way can solve my problem

Upvotes: 3

Ariwibawa
Ariwibawa

Reputation: 667

Another solution is to delete publish profile, this error happened to me after I deleted 1 of the EF DbContext. The solution keep track of that file inside publish folder, I recreated the profile and publish successfully.

My error was this

No DbContext named 'xxxx' was found.

Upvotes: 0

Thomas
Thomas

Reputation: 2942

I had files inside of my directory I intended to publish to. Deleting these allowed for a successful publish.

Upvotes: 0

Murugan
Murugan

Reputation: 692

Delete file showing exclamation mark in the solution explorer. It worked for me

Solution explorer with file

Upvotes: 11

Ogglas
Ogglas

Reputation: 70126

In my case I got a similar error but with .cshtml files like this:

copying to Views\Home\About.cshtml to obj\Release\Package\PackageTmp\Views\Home\About.cshtml failed. Could not find file 'Views\Home\About.cshtml'

Looking at the Solution Explorer tree everything seemed fine with no yellow markings but when clicking on a file it gave an error.

The item 'About.cshtml' does not exist in the project directory. It may have been moved, renamed or deleted.

enter image description here

Removing the files from Solution solved it for me.

Upvotes: 2

Jose A
Jose A

Reputation: 11129

I also bumped to this problem. I was receiving the following error, when trying to publish MVCForum 1.7:

Copying file App_Data\NuGetBackup\Hello.txt to obj\Release\Package\PackageTmp\App_Data\NuGetBackup\Hello.txt failed. Could not find file 'App_Data\NuGetBackup\Hello.txt'.

François Breton's comment helped me achieve the solution.

It's simple:

Open your .csproj file with a text editor (Notepad, Notepad++) Visual Studio will open it as a project.

Press Ctrl + F and search for the file of the problem. In my case the file was "Hello.txt" without commas.

Under the <ItemGroup> it resided:

<ItemGroup>
<Content Include="App_Data\NuGetBackup\Hello.txt" />
<Content Include="Content\admin\Admin.css">
    <DependentUpon>Admin.scss</DependentUpon>
</Content>
...More code omitted due to brevity.

I deleted the <Content Include="App_Data\NuGetBackup\Hello.txt" /> line, and voila! Visual Studio allowed me to Preview before publishing!

It will end like this:

<ItemGroup>
<Content Include="Content\admin\Admin.css">
    <DependentUpon>Admin.scss</DependentUpon>
</Content>
...More code omitted due to brevity.

Upvotes: 48

user3150744
user3150744

Reputation: 34

Check for bin folder is added in vs explorer. If it was there then exclude from project and check. It worked for me.

Upvotes: 0

PontiusTheBarbarian
PontiusTheBarbarian

Reputation: 1030

Right click on your project => unload project => right click again on your newly unloaded project => edit 'myProject.csproj' => Search for the offending files (CTRL + F) and remove.

If the error appears again within the same parent directory, but now under a different file name, it could be that a user has mistakenly included a file in the project (like I did). All files under the offending directory can be removed. This should solve the problem.

Upvotes: 3

mxasim
mxasim

Reputation: 2193

I mistakenly included obj Folder to Visual Studio Project. Excluding Obj folder from project fixed my issue

Upvotes: 1

Anjan Kant
Anjan Kant

Reputation: 4316

Me just removed yellow marked file from my visual studio solution & it worked greatly for me because files were added and removed many times from folders but its not removed from VS solution project.

Upvotes: 13

Abdullah
Abdullah

Reputation: 307

I ran into same problem, i just clicked show all files, and deleted the files that had exclamation mark with them. Hope this helps someone.

Upvotes: 6

Ray K.
Ray K.

Reputation: 2511

Update: I went into Project --> Package/Publish Settings, and clicked "Exclude generated debug symbols." The project began publishing with no issue.

Update #2 (this is probably the better answer): I tried to publish as debug instead of release (yes, I wanted to keep the debug features in this particular release), and the error came up again. It turned out that I did not exclude the CKfinder.dll from the project. Once I did so, it ran with no problem.

Upvotes: 13

Related Questions