'Publish failed' but build succeeded? - asp.net

When using Visual Studio 2008, when I "Publish Web Site", the application builds correctly, but then I get a "Publish failed" message:
What possible reasons are there for this, and how can I prevent it?

I had the same issue. Nightmare to identify the problem, because the logs and outputs show no errors or failures. I simply get "Build: 39 succeeded" and "Publish: 1 failed".
I resolved the problem by systematically removing all NuGet packages one at a time (and removing code that references it) until I identified the offending one.
This takes a LONG time!
However, the answer for me was Microsoft.Net.Compilers.
No idea how I ended up with that in my project, but as soon as I removed that package, everything publishes fine again.
Edit - For what it's worth, this problem occurs on VS 2008, 2012 and 2015 but does not occur on 2017.

You can try this:
Perform precompilation against the web application.
Clear the target directory(virtual directory in IIS or physical file
folder) and deploy all the files (of the web application) into the target
directory.
In the output window you can check at which stage does the publish website
operation fail. For example, at the first stage, if there are some error
which will only occur at precompilation, that will cause the stage 1 fail.
Or some times if the target directory has something configured incorrectly.
Such as the IIS virtual dir is not set to the correct ASP.NET version or
some old files are locked and prevent them from being cleared. Mostly,
publish failed will be caused by IIS side configuration issue such as
authentication setting....
Source link
You can open the output window by pressing Ctrl+W, O.

Sometimes it's because you need to be running VS as Administrator to be able to write to the target directory.
Check the Output messages, they should help you solve the problem

I had to copy project to C:\a\ and than publish. I suspect problems with long path. Strange, but worked for me.

The conclusion is: Try another VS edition and see if that does it.
Here is what did it for me.
I have VS 2013 Pro and Visual Studio 2015 Community. I sort of use one or another to work on my MVC project and all was fine. Then all of the sudden VS 2013 could not publish though it would build just fine. There was no erros other than some silly ...code is not returned from all paths...
So when I open it in VS 2017 - it published the same project just fine. I am suspecting a compiling issue - because that was the stage it would fail at.
Hope that helps you save a bit of time.

Not sure if this happens in different versions of Visual Studio, but at least in 2015 Professional Edition, the problem arises when we try to update all Nuget packages from the solution using the Packages Manager.
As pointed out by #SimonGoldstone the issue is caused by the package "Microsoft.Net.Compilers". By default, the package gets added to the solution while creating a new web application. The default version 1.0.0 does not introduce any problems. I was able to keep testing with latest versions until 2.4.0 and everything works fine, but from 2.6.0 henceforth is when it all starts. If an update is strictly required, I would recommend updating the aforementioned package until version 2.4.0. After doing some research, seems that some bugs on later versions than 2.4.0 are introduced and not fixed on the long term. What is curious though, is how this problem gets included on Nuget with no basic quality control checkpoint.

There are many proposed solutions for this. I think they are overcomplicating the issue.
I found the following worked for me:
Locate the obj(Release or Debug) folder in your solution
Inside the Release or Debug folder delete the CONTENTS of the 'AspnetCompileMerge' folder
Now try and publish.

Make sure you empty the target folder (manually) before publishing. Sometimes vs cant delete a file which will result in a failed publish

After trying a Rebuild, having other Projects in my Solution able to publish correctly, and changing my publish location to the C: drive (locally attached) instead of pushing to a mapped network drive, I was still having an issue where the only error output said:
========== Build: 5 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
My solution is targeting x86, but I think during a Git Merge, this project had it's profile switched to Any CPU. After creating an x86 profile for the project and having it match the target of the publish goal and of the active solution configuration, I was able to successfully publish again.

Check Project BIn directory. there must be a DLL of your page or control. which has to be recreated during publish. So exclude it or remove it

I ran into this same problem today and it was due to the Thumbs.db file that was created when I opened my images folder to look for an image. I deleted the file and the project deployed successfully. Hope this helps someone else in the same situation.

Delete publish profile and create another one . Worked for me

In my case, I was publishing to a directory in a mapped network drive, but the Output panel/window was indicating that the location didn't exist. The path was correct, and the drive was fully accessible. The problem resolved itself when I re-set the path to publish to in Visual Studio by using the ... button.

With me it was simple - the dist folder was locked. I unlocked it by an unlocker and the publishing resumed.

I have several user controls that are registered in the web.config, and have a ClassName in the .ascx file header. For normal builds everything works fine, but with a publish those class names were not recognized anymore. At some point I found out that the errors were not in my regular code files, but in copies in a temp directory for publishing.
I had "Precompile during publishing" turned on (to be found under Settings > File Publish Options). Turning that option off worked for me.

I had the same issue with VS2017 with a website project. Build worked, but publish gave me an error:
Error CS0012: The type 'System.Net.Http.HttpMessageHandler' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
All my projects already had a reference to System.Net.Http so it was really confusing.
To fix it, I had to copy System.Net.Http.dll into my website project / bin folder so publish could find it and copy it to my web host. I found System.Net.Http.dll by looking at another project's references (a class library), then System.Net.Http.dll Properties, and seeing the path (C:\Program Files(x86)\Reference Assemblies\Microsoft\Framework.NetFramework\v4.6\System.Net.Http.dll).

i know iam late but i think it should use for someone whos searching for this query.
just uninstall all your nuget pakages , then clean and rebuilt solution ,
now click on publish , sure it works and u will see publishing starts and works correctly now

If any one had changed the version of the project file and related framework. then this type of issue happened.
please go to "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\Web" location for visual studio published and build setting -> edit -> comment the force copy of all file section.

I had one file that was not found. I had copied in a png file to replace a jpg in the content folder , same name except filetype extension.
Project built fine, but refused to build and publish . changed extension of file so it could find that file name and it worked - no errors amazing 1 thing wrong and everything else is an error.

The case for me was that Visual Studio was not signed in to Azure, but provided no indication of that. I edited the publish profile, clicked "Validate Connection" then clicked "Save" and then it worked.

I was working on a feature branch, which was failing. Switched to Master Branch, deleted the feature one and created another one. It worked.

What caused my issue was a little different, but has similarities to some of the reasons stated above.
I managed to trash my local copy of a given application and did a GIT hard reset to get the most recent from the repository in question. This in turn, wiped out the web.config file (which was not stored in the GIT repository for various reasons).
This cause configuration information for various NuGet packages to be "lost" (since it was stored in web.config).
Fortunately, I had "backed up" the web.config, so once I figured out it was not out there (a migration failed because I was unable to connect to the database), I was able to replace it.
Tried the publish again, after fixing the web.config, and everything worked perfectly.

If you are opting for the "Delete all existing files prior to publish" in the publish web dialog box, then make sure that the Visual Studio is started with Admin rights. Right click the Visual Studio and click Run as Administrator. Hope this helps.

Related

Cannot Git Diff CSHTML Files in Visual Studio 2015

I am using Visual Studio 2015 with ASP .Net MVC 6 on Windows 10. As far as I can tell everything's up to date, but I haven't changed anything recently that I know of. In the last couple of days Visual Studio has stopped letting me compare the current version of an *.cshtml file to see what changes I've made. It works for every other type of file I've tried, only these ones are being a problem.
I am getting the error message "Failed to start the configured compare tool." I've seen a couple of other posts (like this one: Visual Studio 2015 using Git unable to compare files and Microsoft Git Provider and Visual Studio 2012 failed to start the configured compare tool) but they seem to be talking about a more general cannot diff at all problem, which isn't what I'm seeing. It's almost as if git (or VS?) has decided to pick just this one file type to not like.
I have tried creating a new ASP .Net project with a new git repository and it sees the same problem, and the problem goes away if I rename the .cshtml file to give it a different extension. I've had a look in the .gitattributes file but can't see anything, though if I'm honest I don't really understand how git works beyond the basic 'this is how you drive it around when it works'. I've also tried removing and reinstalling everything git related I can find on my PC with no joy.
Anyone have any ideas on what I could have broken?
Update: I've just found this https://github.com/aspnet/Tooling/issues/293 which suggests that it might be related to an ASP .Net Update. Guess I'll probably have to wait and see.
Clearing the MEF cache appears to resolve this also. Close the IDE and delete the contents of this directory:
%LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
Clear MEF Component Cache (Open VSIX Gallery) will probably do the trick as well.
Likely related to https://stackoverflow.com/a/32376450/1154135
This turned out to be related to a problem with the new ASP .Net tooling. They've apparently got a fix to be rolled out, but until then there is a workaround:
In the options panel, go to Options->Text Editor->HTML->Advanced
Set Identity Helpful Extensions to False
This is as per https://github.com/aspnet/Tooling/issues/293#issuecomment-161382206
Check your .gitignore file for references to .cshtml files. Dollars to doughnuts that something like *.cshtml is in that specific repo. Can you run the diff in git outside VS?

My ASP.NET project gets a lot of error. Why?

I made an asp.net website from visual studio 2012 last night and it works perfectly fine. I committed my project in bitbucket then pushed it but when i cloned my code and tried to build and run my project, it gets a lot of error about namespaces and stuff. Why is that? The original files works fine. First I thought maybe I made mistakes, so i tried to commit/push another new project(the default application given from visual studio 2012), but when i clone it, it is still the same error i get. Here are the errors:
https://www.dropbox.com/s/6zn1qbx8kr3avc2/errors.PNG
Do i need to install the packages every time i clone my project?
In nuget options, you can set up to Enabling Package Restore During Build :
This will set up your project to maintain packages list, and to redownload missing packages.
I'm not too familiar with BitBucket, but from the looks of the errors, it appears your missing a lot of your dll's. One thing to check would be ensure that your referenced dll's are set to Copy Local = true. (Solution explorer -> References -> Right Click Dll -> Properties -> Copy Local = True). That should ensure that wherever your copy/publish the solution, the dll's go with it.

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!:)

Why am I unable to Debug my ASP.NET website in Visual Studio?

I used to be able to attach to my w3wp process and Debug my web application, but this is not working anymore. I have no idea what changed to break this. I'm using Visual Studio 2008 SP1. And I'm debugging in IIS, not using ASP.NET's own server (i.e. I don't Run my project, I simply attach to a running process (w3wp).
My breakpoints simply have the "breakpoint will currently not be hit. The source code is different from the original version."
What I have tried:
Did a solution Clean.
Did a solution Rebuild.
Made sure that compilation debug=true in my web.config file.
Deleted the bin folder
Restarted Visual Studio
Restarted IIS
Restarted my Computer
Added a simple Response.Write to ensure that the latest DLL is being used. It is.
Made sure that Debug ASP.NET is checked in my project properties. It is.
Made sure that all my projects are compiled in my build configuration. They are.
But none of these help. I attach to w3wp, but my breakpoints never get hit.
Any ideas?
I had this problem recently and I ended up first making sure Visual Studio was not running at all on the system.
Then went into this folder and deleted all its content:
C:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
Check your web.config for
<compilation debug="true">...
When you "Attach to process", the Output window should show you (when showing output from "Debug") all the libraries it's loading, and where it's loading them from - for the dll's in your /bin folder these are usually copied to the \Temporary ASP.NET Files\root\ folder - where are yours being read from? Have you definitely cleared them out from there?
The only other things I can think of:
You've compiled your code in "Release" mode rather than "Debug" (not the web.config) from the Solution Configuration drop-down.
The symbol files (.pdb) are missing from your /bin folder.
On the "Build" tab of the project properties, you are in configuration "Active (Debug)", you haven't check "optimize code"?
If you click "Advanced..." on that tab, what value do you have for "Debug Info"? Is it "full" or "none"?
Responding to comment
You will find it harder to debug successfully if your code compiled in "Release" mode, and you'll often get the "source code is different" message when you've not rebuilt the symbols (.pdb files) after changes - but you say you've done a clean/rebuild, so that should cover that.
Yes, your output window will show all the framework dlls that you're referencing as well as your code - but you should see one file listed in there with the name of each project output - those are the ones to look at.
You don't have some post build event that moves files into the correct directory for your site do you that's silently failing?
I also had this problem, solved it by changing the "Attach to" code type to Automatic on the "Attach To Process" dialog. (Previously I had this set to "Silverlight Code" due to debugging a different process... it can be easy to forget to change this back.)
I know this issue has been open for some time, but I think it is the same as I experienced:
I could not debug my .aspx server side code. I had a working WepApp AnyCPU project and I wanted to link to some x86 dlls, so I created an x86 debug target. Did similar things, rebuilt, stopped the development web server, rebooted, clear temporary files, all to no avail.
Fixed the problem by changing the target folder to bin\ (was bin\x86\Debug).
Are you running any add ins that could be affecting this? Or any tools that apply post build operations to the source code that the DLLs you start debugging with have been modified post build and it actually is correct that it's not the same source code so debugging won't work?
Also have tried resetting VS?
devenv.exe /resetsettings
Edit: if none of the information has aided you here, while painful it might be worth uninstalling and reinstalling VS and SP1. If you go through this and the issue is the same afterwards that atleast assures that the issue lies in either the web.config or the project settings.
Did you check your assembly.cs file with this attribute
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default)]
After reflecting a optimized code you will probably get this. So you must remove this to be able to debug again.
I faced the same issue. The w3wp process took a lot of memory and did not want to be reset on web application publishing.
Press Ctrl+Alt+Delete > Go to "Processes" tab > find w3wp process and
kill it. Run the app again (if this is an mvc app, just go to a
related url to automatically recreate w3wp process).
Warnings will disappear after that.
I have tried all the below options in my Visual Studio 2013 Update 4.
Reset IIS
Clean solution and rebuild
Delete the friles from temporary folder
C:\Windows\Microsoft.Net\Framework...\Temporary ASP.NET files
Check whether the compilation tag is debug or not
But none of them worked, here I am listing down the two things which worked for me.
Disabling the "Just My Code" option
Tools ->Options -> Debugging -> General -> Uncheck Enable Just My Code.
Edit the web.config file and save (You can always create a space in any line
in web.config, that will do)
Please be noted that this solution can be Visual Studio version specific, and the both fix worked for me in my Visual Studio 2013 Update 4.
in the "Attach to process" dialog, click the checkbox (near the bottom) for "show processes from all users" and if you see two w3wp.exe processes, try the other one.
One should have a comments/description value of something like T-SQL, managed somethingoranother. This is the one you want.
I have had this problem for a while and found my solution on the MS forum (link below).
Debug Diagnostic Tool was the culprit for me, but I did not have to uninstall it. I had a crash rule set up for the w3wp process and I simply removed that rule and restarted everything.
Microsoft Forum for Unable to attach error
On OpenVMS we just used to:
Compile/Debug then Link/Debug
and that was it! Simples!!
but seriously, make sure the file you have your Debugger.Break line in, has 'Copy always' set in its Properties before re-building
I was using the Visual Studio extension VSCommands to attach the debugger (convenient). However, IIS Express was running, and I guessed it might be interfering. Sure enough, when I closed IIS Express, suddenly I was able to debug again.
Joy ensued.
In my case I had a Console Application the hosted web page in .Net Framework 4.6.1. When I added a Debug to Conditional compilation symbols, it started to work:
Make sure that "Current Page" and not "Don't open a page. Wait for a request from an external application." is checked under Properties->Web->Start Action.
add this code in your .csproj file
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

ASP.NET website does not rebuild

I have a solution with several projects in Visual 2008, let's say SuggestionProcessor (a class library) and Suggestions (a website) with a webhandler GetSuggestions.ashx. I changed a method in SuggestionProcessor which is used in the webhandler. The call in the webhandler has been adjusted to the changed method.
But now when I try to execute the webhandler after a rebuild I get an error that the method I changed is missing, displaying the old method signature. When I try to rebuild the entire project it seems that the website does not rebuild properly and the code I changed in the webhandler does not seem to be included in the rebuild. I made sure that the website is last in the build order.
What I tried is remove the dlls that the build process should rebuild from the bin folder (not the ones referenced from outside the website). When rebuilding I now get a: 'could not load type Suggestions.global'. Duh, that is what the build process should create. What is going wrong here?
I solved this one by reverting to a previous state when it still worked.
Thanks for the suggestions, I'm sorry they didn't work in my situation.
Shall I delete this question now that it doesn't really have a clear use for someone else?
I would check your web.config file, there may be references there that are causing the error since they are missing.
Maybe try and right click on your solution and select "Clean solution" and then try and rebuild all.
If that doesn't work, check your solutions build configuration and make sure all your projects are getting built
Try "Clean Solution", then building SuggestionProcessor, and after that clean and rebuild the web solution.
Visual Studio creates a copy of all your DLLs and sometimes this copies are not refreshed.
Just execute iisreset and delete all folders in:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary
ASP.NET Files\
Of course change windows installation folder and framework folder to your version!
I don't think so... I've seen similar issues in Visual Studio 2008 working on web projects where the build and rebuild would fail time after time. I knew that my changes shouldn't have affected the build so I just kept cleaning and building each of the individual projects in my solution until finally (and I do mean finally as in, it took up to 10 builds) my web project would build correctly. I have no idea why, but it feels like some sort of caching issue.
From my answer at "Could not load type [Namespace].Global" causing me grief:
It seems that VS 2008 does not always add the .asax(.cs) files correctly by default.
In this case, refreshing, rebuilding, removing and re-adding, etc. etc. will not fix the problem. Instead:
Check the Build Action of Global.asax.cs. It should be set to Compile.
In Solution Explorer, Right-click Global.asax.cs and go to Properties. In the Properties pane, set the Build Action (while not debugging).

Resources