"Swap out" VS projects in solution maintaining source control - asp.net

I have a solution with several projects. One of these projects is a "Web Site" I need to convert into a "Web App", following the steps outlined at http://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx
Those steps create the web app as a new project, instead of replacing the old one. Now that I have the Web App working, I need to replace the old one, but I don't want to lose the version control or other TFS things.
So far, I've tried simply replacing the files in the Site project's folder with the files from the App project's folder, but Visual Studio still sees it as a Site. So I edited the .sln file to point to the .csproj, but VS tells me the project "needs to be migrated" (and if I try to do that, it fails).

Deleting project and adding a new one won't lose the version control. When you select Show Deleted Items, you still can view the history of the deleted Web Site project:

Related

Why are changes to my WebJob not being picked up when publishing the Web App?

I have an ASP.NET MVC Web App which is deployed to Azure. The solution within VS 2013 Pro has 3 projects:
the Web App project
a Webjob project
a Common project which stores code which is common to both the App and the Webjob.
The Webjob project was added to the main App project via the Add --> New Azure Webjob Project context menu, which actually adds a new project within the same solution, which is fine.
When I initially published the app to Azure, the Webjob was deployed too and all is working as expected. The Webjob runs on schedule once per day.
Now I've made some local changes to the Webjob and need those changes to be published. I follow the same process to deploy the App (rtClick main App --> Publish) which should also pick up changes to the Webjob, but the Preview pane is not picking up the changes and the changes are then subsequently not published to the Webjob.
Incidentally, any changes I make to the Common project are picked up successfully so looks like there is something weird about making changes and publishing Webjobs.
Has anyone come across this before?
I've found the cause of the problem. It's actually very simple but also pretty frustrating.
When publishing the web app, you have the option to Remove additional files at destination. I have always left this checked because I don't like old files hanging around for no reason.
You also have the option to Exclude files from the App_Data folder which I also always leave checked so that files from App_Data are not deleted based on the remove configuration above. I then usually configure things like NLog log files, ELMAH xml files etc to go into App_Data safe in the knowledge that anything in there won't be deleted.
So the issue with Webjobs is that they're deployed into App_Data. So if the Exclude files from App_Data folder is checked then when the app is published, it's doing what it's told and ignoring App_Data and hence ignoring the changes to the Webjob.
So the simple solution is to uncheck this option and the Webjob is deployed successfully. However the issue now is that all other files in App_Data will be deleted (log files etc).
So you could uncheck the remove files config but that then potentially leaves other unwanted files lying around. Not ideal.
The other option is to leave the remove config checked, click the Preview button within the Publish dialog prior to publishing, then manually unchecking every file you don't want deleted. However the publish process fails if any of the files you want to keep are within sub-folders within App_Data e.g. App_Data/logs.
So the other option is to move all of the files within App_Data that you want to keep into the root of App_Data, then uncheck each of them within the Preview window prior to publishing. Not a huge deal when done once but becomes tedious when publishing lots of times.
I realise I could move log files etc to Azure storage, SQL DBs etc but what if it's the case that other files are in App_Data which need to be kept? App_Data isn't solely intended for Webjobs but using Webjobs creates a bit of an awkward situation if you also use App_Data for other things.
Be keen to know if I'm missing anything obvious here?
Try to do a 'Publish to local file system' in VS, and check if the WebJobs files make it that folder (under App_Data). And if that works, try making a change to the WebJob and then do an incremental publish to the same folder. You can find more info relating to this here.
Normally, whatever file set you get to your local folder is what would get deployed to your Azure Web App.
If the same issue occurs locally, then there is probably something wrong with the WebJobs NuGet package in your app. You could try checking for NuGet updates.
Yet another thing you could do to further isolate is to create a new clean dummy WebApp with a WebJob, and see if you see the same. This will help determine if it's specific to your one project.

Deploying as ASP.NET website DLL

a year ago I created and deployed a simple web app from visual studio 2012. This included a dll in the bin folder containing the code behind.
Fast forward one year and I need to make a small change to the .cs file.
I open the solution in VS2012, make my change and select build project. No bin folder and no dll are created. I try build website, rebuild website and anything obvious I can see but even though the build process works fine I do not end up with the bin folder or the dll. I have double checked the live site and the web site contains a bin folder and a dll rather than individual code-behind files.
Have I missed something obvious or fundamental here?
Have solved this now. The compilation of the dll happens at the publish web site stage and not the build web site stage. Once I sorted out an issue with FTP I was able to publish to the live site and the dll was overwritten with my new one

Web Application won't publish without .cs files

I have an asp.net web application project that I am publishing via Build > Publish within visual studio 2013. I am publishing to the file system, using the precompile option selected. My project has "Only files needed to run this application" selected in the Package/Publish Web settings screen. However, regardless of what I do, the .cs files (code-behind) and designer.cs files get copied to the output folder during publishing.
This project was created by using the File > New Project > ASP.NET Web Application functionality in visual studio. Then files from a website project were added to the application, and the "convert to web application" command was run on it from the build menu. The conversion to a web app seems to have worked fine, but I am unable to publish without the .cs files being included.
What else needs to be done in order to get a web application to publish without the code-behind files included? Any ideas on what I can look into?
Could there be a setting at the solution level that is causing this? The new web application was added to a pre-existing solution with about a dozen other projects.
Another thing to note is that when I create a new web app with visual studio in a new project, and publish w/ the same settings, it does NOT include the .cs files.
I've also tried deleting and then creating a new publish profile.
I just fixed this by deleting my old publish profile and creating a new one.
The new one appeared to have all the same settings as the old one but when I published it didn't copy the .cs files.
Edit: This answer is a lie. There was a difference between the two profiles. The new profile was in Release configuration.
Edit 2: There's a setting in the project settings which determines what gets published. Select "only files needed to run this application" from the following page.
Turns out that I added this line to my csproj file earlier when I was trying to get my project to build on our build server. Removing it fixed the problem:
<Target Name="GatherAllFilesToPublish"></Target>

Old VS2008 ASP.NET web site project doesn't update DLL in bin after building

I have inherited an old ASP.NET web site project (not a web project), so it uses the web site model from what I gather. There is no code in the App_Code folder. There are dozens of aspx and aspx.cs files in a different folder.
What I have done so far:
I have copied the entire project locally from the previous person's fileshare (he's gone and didn't use TFS).
I loaded the web site in VS2008, made a small change to an email address in the code and rebuilt it.
At this point, it compiles fine, no errors. But the dlls in the bin folder do not reflect the proper date/time stamp. I published the site to the test server and it is still using the previous email address before I updated it.
My problem: Why would the dll not get updated? I have read there is a difference between a web site model and a web application model. When I select Build from the menu, it actually says "Build Web Site", and not the project name. This is my first experience using this type of project.
My Question: Any ideas what I can do to resolve? I have already combed through similar questions on this site but the ones that are closest to my issue don't have resolve/answered status.
Thanks
From what I recall, didn't websites perform runtime compilation and hence not generate a dll? Don't quote me on that though, it's been a while. Could you convert it to a web application from VS?
You should have a solution with at least two projects:
Sln
- Website
- DLL
On the Website add a reference to the DLL and build. Should take care of it.
Alternatively you could convert to a Web Application as well, but you'd have the same problem if your project structure is not correct.

How can I use the "Publish" function in Visual Studio 2008 without erasing the contents of the target folder?

When I use Build->Publish Web Site in Visual Studio 2008, most of the time it compiles the site, and then simply asks me "All files in the target folder will be deleted. Continue?" (or something to that effect). On occasion, however, when publishing a project in Visual Studio, I would get a dialog box that would give me the choice of replacing the folder's contents completely, or simply replacing changed files with newer version.
I much prefer to publish without completely obliterating the folder, because the deployed application creates user files and cache files as it's been used that I don't want to take extra steps to preserve. However, I'm not sure why Visual Studio doesn't always give me this option. Is this a setting somewhere I can change? Is it tied to the version of .NET I'm using?
Any insight is appreciated!
Edit - Followup on 2009-01-20
I still haven't figured this out, but here's some more information.
Here's what the publish function looks like for one ASP.NET project on my Win XP desktop:
And here's what it looks like for a different project on my Vista laptop:
Notice the radio buttons in the second screenshot that allow me to choose to either delete the contents of the folder prior to publishing, or merely to overwrite matching files. I'd like to have these options for every project.
Both computers are running Visual Studio 2008 Professional (version 9.0.30729.1 SP, according to Help->About). The exact same version. And I doubt the OS difference is causing this functionality change. It's got to be a setting somewhere, right? Does anyone know?
John is right, the only difference is one of your projects is a Web Site Project and the other is a Web Application project. You will not see the "convert to web application" option unless you are in a Web Application project. I know... it is very misleading. The reason behind this stems from the the way you convert to a web application project. If you plan on converting it(which can be a real pain in arse, depending on how it is set up) then you need to be aware of a few differences:
In a Web Application project everything is pre-compiled all the codebehind pages will be compiled into a .dll ---- In a Web Site Project nothing in the project is pre-compiled, the compiler will compile everything to ensure it is valid but none of the compiled pages are uploaded. When a user first attempts to access the site each page is compiled into its own dll. This means in a Web Site Project you are able to upload a single codebehind file.
Namespaces - In a Web Application project namespaces are created by default in a Web Site Project they are not. So you may have to spend some time adding them if you plan on converting them.
Project files - you will notice that A Website Project does not have a "cproj" file a Web Application project does.
I have converted a few of these project I find they go fairly smooth as long as there is not a lot of code in the "app_code" folder. You can give it a try and see how easy it is, if it looks like it is going to be a pain, I would suggest FileZilla just FTP it and save yourself some headache.
Good Luck
That dialog is different for Web site projects and Web application projects. In my MVC projects (Web application projects), I see the additional options. In my regular ol' web site projects, I see the first dialog posted.
Not sure if this option will be suitable for you but you could use the copy website function from the solution explorer. Click on the "Copy Website" icon at the top of the solution explorer.
I think the real answer to your question is that you should put your user files and cache files somewhere else.
When publishing a web site Visual Studio is designed to make sure that the target folder contains your web site files, and absolutely nothing else.
Apparently this feature is coming in VS2010 - that's what Vishal Joshi announced at TechEd EMEA in session "PDC307: Microsoft Visual Studio 10: Web Development Futures"
The site has been updated from the site in the updated layer.

Resources