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

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?

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.

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.

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.

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

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.

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.

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.
Removing the files from Solution solved it for me.

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

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

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

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

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.

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

Related

Cannot navigate to the symbol under the caret

we just migrated to vs2019 and when we try to use F12/"Go To Definition" we are getting "Cannot navigate to the symbol under the caret". F12 seems to work for variables that are defined inside the same file but is failing when trying to go to definitions that are in a different project.
This is happening only on some of the projects inside the same solution. both working and non working projects have the same Target Framework of 4.7.2.
all projects are still compiling properly and as far as we can tell this is the only symptom.
I have tried clearing the symbols cache, deleting the .vs hidden folder, cleaning and rebuilding the solutions. deleting the bin and obj folders and rebuilding. but no luck.
Update "Microsoft.Net.Compilers" in Manage Nuget Packages for Solution.
This worked for me.
This post got me close to the solution
https://developercommunity.visualstudio.com/content/problem/505489/cannot-navigate-to-the-symbol-under-the-caret-3.html
unfortunately my package manager was not showing "Microsoft.Net.Compilers", but once I opened the vbproj files in a text editor I was able to remove the following lines:
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
I got the same issue, here is solution which worked for me.
Close the VS
Reopen as an administrator.
Clean the solution
Rebuild my solution
In between try updating the nuget package, i updated my .net core nuget package to 2.1
For me the problem was that I was looking at a new file that was not added to the corresponding .csproj so Visual Studio didn't know how to make sense of the references located in my new file.
Double-check that your .csproj contains the file that you're experiencing this problem in.
Your compiler needs to be updated to the latest. I had the same issue and these are the steps I took to resolve it.
Right-click on "References" in the Solution Explorer
Select "Manage NuGet Packages"
Under the "Installed" tab search for "Microsoft.Net.Compilers"
Select "Microsoft.Net.Compilers"
On the side window of "Microsoft.Net.Compilers" click the update button

ASP.NET Publishing Web App Copying File Error When the File Has Already Been Deleted

I'm having a very peculiar issue in Visual Studio when trying to publish my MVC Web App on IIS, Windows 10. It is trying to copy a file that no longer exists in my solution. This is the error:
Severity Code Description Project File Line Suppression State
Error Copying file obj\Release\AspnetCompileMerge\Source\Views\Demo\File.cshtml to obj\Release\Package\PackageTmp\obj\Release\AspnetCompileMerge\Source\Views\Demo\File.cshtml failed. Could not find file 'obj\Release\AspnetCompileMerge\Source\Views\Demo\File.cshtml'. Solution 0
This file does not exist anywhere in my solution so I am unsure as to why it's trying to copy this file. I've tried restarted Visual Studio, cleaning and rebuilding my solution, deleting the .vs folder, but all of this has been for naught.
Solution 1
After you deleted file from folder (Not in the visual studio) usually become this error message. the reason for your "projectname.CSPROJ" file already recorded your deleted file reference
Eg : <Content Include="Views\home\Index.cshtml" />
Then you can to delete that reference from in your "projectname.CSPROJ"
Solution 2
if you can see file in the project, You can right click on the file and Exclude file from the project
after that you can publish your project without error
I am using VS 2019 and was getting the same error.
For me the reason seems to be the solution location. The file path was exceeding 200 chars.
After I copied the solution in c: drive it started working for me.
Try,
Right Click -> App_Data -> Click Exclude from Project.....
If you get an error like this it's better just to migrate your project to a new solution, that's what I did.

Publish of application fails to find file that exists

I've run into this issue when trying to publish my application today that I have published many times before. I'm trying to publish to a directory.
The issue I have is, if I go to my app directory C:\www\clients\clientsite\app\clientproject\Properties\PublishProfiles where the error below says it can't find the file I can clearly see the git.pubxml file.
Copying file Properties\PublishProfiles\git.pubxml to obj\Release\Package\PackageTmp\Properties\PublishProfiles\git.pubxml failed. Could not find file 'Properties\PublishProfiles\git.pubxml'.
I've checked directory security settings and those are proper. I tried deleting my bin and obj but nothing is making a difference.
Often times the solution here is to edit the project file itself in notepad.
The trick to finding the afflicted path is to inspect the OUTPUT window, not the ERROR LIST window.
Once you find the afflicted file path, search for it in the project file and remove the reference.
In most cases the troublesome lines in the project file look like :
<Content include="{your path}" />
Continue to remove the includes until publishing works.
IMPORTANT: if you keep Visual Studio open while you're doing this, you must accept the "reload all" prompt.
I just ran into this after removing all unversioned files from my filesystem (which caused some .pubxml.user files to be lost.
If you right click the project node and click "publish", then select the publish profile that is causing problems, then simply close the publish dialog, Visual Studio will ask if you want to save changes... when you click yes, it regenerate the .pubxml.user file and everything works again.
Have you ensured that the file actually exists in the project? I have had problems working in a team where some file I wrote ended up not appearing in VS as a project file, so when we published, it didn't exist in the publish. If you can't find it inside VS, ensure that you are not debugging, and drop the file into the project file structure, then publish as normal.
VS was saying it couldn't find that file because the git.pubxml file in that directory was of type USER File and it needed to be PUBXML. When I added the correct file type from another version of that same project, I was able to publish the project again. I believe the PUBXML file was removed by mistake in source control.
It usually happens to binary files after updating it. Some packages remove it's own .xml and .pubxml files, while visual studio still believes that it is a part of the project.
What you need to do it to check for a Yellow Triangle besides the file name in the project directory tree, and remove that files, they're useless since your project compiles without errors.
try changing the publishing settings. if you check "Precompile during publishing" this will recreate your .pubxml.user file
I looked in Solution Explorer under the PublishProfiles section and found that the file was excluded and had a "!" by it showing a warning that the file wasn't found. I deleted it, then went into my Publish settings to edit a profile. I changed something (for me to compile files during publish.) Then I tried republishing the solution, and it worked!

unable to write output file ... pdb visual studio 2010

From other answers to this same question, it seems that this error is secondary to the real problem which is a missing source file. I am not using any source control. I have looked through my entire project and don't see any files with a warning icon, indicating it's missing. If there IS a file missing, what is it missing from?
How can I find the "missing" file? Isn't there any way of resetting this? My whole project is stuck on this.
I had this too. Close VS and reopen. Don't compile. The errors list should tell you which file is missing.
I too had this problem. My project was building in release mode but was not working in debug mode. I checked for all necesary files are included in my solution and I found that there is one file missing Settings.Designer.vb in My Project folder. I included these file in project and it build file in debug mode also.
Make sure that all aspx files are available in your solutions, otherwise check WebSite.vbproj, make sure maybe there is a file that is missing from your code, either add this file to the solution, or remove it from WebSite.vbproj. I recommend for you to use Notepad++ to open and modify WebSite.vbproj
Regards,
Luai
Another possibility is the existence of corrupted compiled dlls for the actual project (i.e. bin/<project>.dll) In my case, I just deleted the .dll and the .pdb and recompiled and the error went away.
Deleting removed files from the Solution Explorer, then rebuilding, solved it on my computer.

Visual Studio 2012 Web Publish doesn't copy files

I have a Web Application project in VS 2012 and when I use the web publishing tool it builds successfully but doesn't copy any files to the publish target (File System in this case).
If I look at the build output I can see everything gets copied over to obj\Release\Package\PackageTmp\ correctly but then all I see in the build output is this:
4>Done building project "{Project}.csproj".
4>Deleting existing files...
4>Publishing folder /...
4> ========== Build: 3 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
Even though it says the publish succeeded there are not files in the target directory for the publish.
I have seen this in multiple projects and sometimes it seems like the Solution/Platform configurations cause this problem but I haven't been able to pinpoint an exact cause for this.
Has anyone else seen this happening or have an idea on how to get this working correctly?
UPDATE:
I may have found a workaround for this. I just had this happen again and I was messing around with the publish settings. Once I changed the selected Configuration on the Settings tab away to another configuration and then back to the one I wanted to use all my files started publishing again. Hopefully this works on other projects in the future.
UPDATE 2:
I posted a bug on Microsoft Connect and heard back from a developer on the VS Web Developer team. He said they have fixed this issue in their internal builds and will releasing an update to the publish tool soon that will fix this problem.
UPDATE 3:
This has been recently fixed with Visual Studio 2012 Update 2
Same problem. The workaround was changing the publish settings from Release to Debug. Re-publish and then change back to Release...
This may be caused by solutions/projects that were created with the RC of vs2012. This happened to me months ago and fixed the problem by making sure my solution build configurations matched my project configurations...
I just recently experienced the same problem when opening the same solution originally created in vs2012RC with VS2012 Express for Web. I did exactly what the original poster suggested and it fixed my problem.
Here is the thread that lead me to the answer:
connect.microsoft.com/VisualStudio/feedback/details/746321/publish-web-application-fails
The pertinent response from the conversation above that helped me was:
Posted by Microsoft on 6/13/2012 at 12:00 PM Hi Andrew,
This was a bug in how we handle the solution configuration vs. the
project configuration. We incorrectly assumed that they would be the
same (e.g. Solution's Release|x86 would have each project set to
Release|x86 as well), which caused us to use the wrong build
properties for publishing files.
The workaround is to make the solution configuration and build
configuration match. This issue will be fixed in the next release of
Visual Studio 2012.
Thanks,
- Jimmy Lewis SDET, Visual Web Developer team
To take this a bit further. You have two files that are created when you create a publish profile.
NewProfile.pubxml
NewProfile.pubxml.user
When you open a project that has these files in the PublishProfile folder from a source control it only has the .pubxml file and not the .publxml.user file, so it creates the .publxml.user file on the fly when you open the project.
When it creates the new .publxml.user on the fly the xml looks like:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
When you create a new profile it creates xml that looks like:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<TimeStampOfAssociatedLegacyPublishXmlFile />
<EncryptedPassword />
</PropertyGroup>
</Project>
If you take the <PropertyGroup> node and put it in the .pubxml.user file your PublishProfiles will start working again.
An easy fix is to delete your publish profile and create a fresh one.
when you right click on your solution and select publish, you have a profile set. delete this and create a new one.
this will fix it.
I had this problem from switching from 2010 to 2012
I had same error and I change the setting from release to debug and the problem resolved..
I had this same problem however none of the answers in this thread worked for me. My issue was that there is a directory that contains dynamically generated (by my app) static HTML files. The entire directory was not being published.
The solution that worked for me was found here:
One issue I got a while back and thought I should document was that certain file types were not being uploaded when I published my project.
The file types in question were .pdf files and .rtf.
The reason this happened was because these file extensions were not recognized as requiring publishing by Visual Studio. Luckily this can be changed in Visual Studio.
Select the file(s) that aren’t being copied. In Properties ensure that Build Action is set to Content.
If this doesn’t work the following can be tried.
Under the Project menu select Package/Publish Web and notice this drop down:
Try changing this to All files in this project folder.
This is because the .pubxml.user contains required information to publish, and that file isn't (and shouldn't) be included in source control. To fix this VS bug, copy the information from the .pubxml.user file to the .pubxml file. The relevant properties are:
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
Put those in your .pubxml and you should be good to go.
I tried all of these solutions but this is the one that works every time.
We just change the "Publish method:" from "File System" to for example "Web Deploy", and immediately change it back to "File System".
I have (had) the same problem for several projects. The only ones hit seem to be web projects. Deleting and recreating the profile solves the problem only once. Additionaly, comparing the publishxml generated yields no differences, so it does not seem related to the profile at all.
The workaround mentioned by OP to change build problems back and forth seems the only reliable solution at this time.
I ran into the same problem on VS 2010, after checking publish output, event logs, turning on and checking visual studio logs etc I then decided to remove the web publish (via add/remove) which I believe had been recently updated to v1.0.30810.0. This resolved the problem.
Here we had the same problem.
We just change the "Publish method:" from "File System" to for example "Web Deploy", and immediately change it back to "File System".
The following worked for me:
Simply change from Release>Debug>Release (or vice-versa) and then publish.
No need for deleting, editing, publishing anything you don't need to.
My problem was in wrong configuration of myproject.csproj file. '_address-step1-stored.cshtml' file did not copy on publish. 'None' changed to 'Content', now it's ok.
Same problem with VS 2012 Pro with a disk publish target. Project used to publish correctly but started doing this issue where it failed to copy the files to the destination folder.
Solution was to edit the publish profile, change the mode from Release (Any CPU) to debug then back to Release (Any CPU). Doing this causes the PublishProfiles\projname.pubxml.user file to be rewritten (as described above). Looks like it added the LastUsedBuild,LastUsedPlatform and TimeStampOfAssociatedLegacyPublishXmlFile elements under the propertygroup node. After the publish is complete, it adds another ItemGroup with individual files and publish times.
For what it's worth, I eventually gave up on fighting with Web Deploy to get it to do what I wanted (copy deployable files and nothing else), so I scripted it in PowerShell and am really happy with the result. It's much faster than anything I tried through MSBuild/Web Publish, presumably because those methods were still doing things I didn't need.
Here's the gist (literally):
function copy-deployable-web-files($proj_path, $deploy_dir) {
# copy files where Build Action = "Content"
$proj_dir = split-path -parent $proj_path
[xml]$xml = get-content $proj_path
$xml.Project.ItemGroup | % { $_.Content } | % { $_.Include } | ? { $_ } | % {
$from = "$proj_dir\$_"
$to = split-path -parent "$deploy_dir\$_"
if (!(test-path $to)) { md $to }
cp $from $to
}
# copy everything in bin
cp "$proj_dir\bin" $deploy_dir -recurse
}
In my case I'm calling this in a CI environment (TeamCity), but it could easily be hooked into a post-build event as well.
This action was successful for me:
Kill Publish Profiles in "Properties>PublishProfiles>xxxx.pubxml" and re-setting again.
I found the I could get around this problem by changing the target location from obj/[release|stage|..] to a new path outside of the solution folders completely eg c:\deployment. It seems like VS 2012 was getting confused and maybe giving up somewhere during the publish process.
Matt
Had the same problem recently in VS 2013 for a MVC project in which I imported Umbraco CMS. I couldn't publish. The answer above helped, though I needed a while to figure out what I actually should do in VS. It needed some research e.g. on MS blogs to find out. I try to say it simple:
Choose in the VS toolbar a certain configuration e.g. Release and Any CPU. Run the project.
Afterwards right-click in the Solution Explorer on the solution in question, choose Publish. Create a new publishing profile or use a given one, but always make sure that in the settings the same configuration (e.g. Release and Any CPU) is chosen, as before you run the project the last time.
Additionally in my case it was necessary to delete the OBJ folder because here the settings from my last unsuccessful tries to publish got stuck, though I restarted VS and deleting all publishing profiles.
I have a Web Application with several other referenced Projects in the Solution. I've deployed successfully with a single Publish configuration many times in the past. I changed the Project Configuration from Debug to Release for a Project that had been missed in the past. The next time I attempted to deploy I got these symptoms, where the Publish just quietly fails - it does nothing and says it succeeded:
1>------ Build started: Project: Project, Configuration: DeployProduction Any CPU ------
1>
2>Publishing folder /...
========== Build: 1 succeeded, 0 failed, 9 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
The only way to recover it was to wipe out the Publish profile, close Visual Studio to force it to save the deletion, reopen it, and recreate the Publish profile from scratch. Once I did that I could Publish fine again.
Win8 VS2012, crappy laptop.
In Visual Studio 2012, switching between releases still causes problems.
We added a pre-build event to delete the obj folder: del /s /f /q $(ProjectDir)\obj and it fixed the issue of publishing. Cleaning works sometimes, but not always.
I finally found the answer by myself. All of the above solutions doesnt work for me.
What i had done is that i move the project to drive c change the project folder to something shorter and boom it publish..
the reason that it failed on my side is that i had very long project name/heirarchy.
C:\Users\user\Desktop\Compliance Management System\ComplianceIssueManagementSystem\ComplianceIssueManagementSystem
I had thought of this because sometimes when i extracted rar file it says that the name/path is too long. I thought it will be the same as visual studio 2012 publish. and it does!
hope it will help you guys.
Check your current project that whether you have made back copy with same class name and different page name (Class name will inherit copied file). Ultimately that will confuse the compiler!!!
CodeFile="Consolidated.aspx.vb" Inherits="Consolidated
None of the above solutions worked for me.
But I noticed that of our five ASP.NET MVC projects in our main solution, four of them put the deployment package in the right place, while one left it under obj\Debug.
I compared the projects and found a discrepancy. The solution was to change this:
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
to this:
<Import
Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets"
Condition="'$(VSToolsPath)' != ''" />
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"
Condition="false" />
After I made this change, all five projects put their deployment packages in the right spot.
(Sorry about the long lines, but I couldn't find a better way to condense them.)
I encountered this with Visual Studio generated Service Reference files becoming too long in terms of the overall path length.
Shortened them by re-generating the Service Reference using svcutil.exe, deleting all the original Service Reference files.
svcutil can be called like this:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\SvcUtil.exe" /language:CS http://myservice /namespace:*,My.Namespace
My.Namespace should be replaced with the existing namespace in the generated service proxy (typically found in the Reference.cs file) to avoid compilation errors.
http://myservice should be replaced with the service endpoint url.
I've got into same problem. None of the above solutions worked for me.
So, I've excluded the files which failed to copy while publishing.
I had published the website several times. But one day when I modified some aspx file and then tried to publish the website, it resulted in an empty published folder.
On my workaround, I found a solution.
The publishing wizard will reflect any error while publishing but will not copy any file to the destination folder.
To find out the file that generates the error just copy the website folder contents to a new folder and start the visual studio with that website.
Now when you try to publish it will give you the file name that contains errors.
Just rectify the error in the original website folder and try to publish, it will work as it was earlier.
Follow these steps to resolve:
Build > Publish > Profile > New
Create a new profile and configure it with the same settings as your existing profile.
The project will now publish correctly. This often occurs as a result of a source-controlled publish profile from another machine that was created in a newer version of Visual Studio.
FIXED - various solutions offered didn't work for me. What did work for me with VS Community 2017, Windows Server 2012 R2 was to change the TEMP and TMP environmental variables for the user and then restart the system and deploy again (restarting VS was not enough). These temp variables are where VS does the temp publish.
Restarting visual studio after changing temp variables didn't do the trick, had to reboot system.
Try quitting Visual Studio, delete the relevant pubxml.user file in your PublishProfiles directory, restart VS and publish. Worked on VS 2019.
First:
Build in release Configuration.
In Project Properties-> page select All files and folders under
Package/Publish Web.
Rebuild solution (after Clean solution).
now publish.
While publishing recheck what u have opted.
this should do it. It did for me!:)

Resources