Visual Studio Project restore old version - asp.net

I am working on an ASP.NET web project in Visual Studio 2013 and it worked couple of hours before. But an hour ago I was tweaking something in the project and messed up the entire project. Is there anyway to restore to the version I had yesterday?

If you are using Version control, such as Mercurial, GIT, Subversion, TFS -- and you remembered to commit your work then YES, definitely.
If you're not using Version Control then you need to ask yourself why not? And don't turn off the computer today until you've corrected that oversight.
Also, you may have previous versions/restore points saved for you in Windows. In windows explorer, right click on the folder where your work is being saved and select properties. They may be a 'previous versions' tab, and inside there you may be able to revert to an earlier version. If so: lucky lucky you.
Also, if your work is being shared using a service like DropBox, you will be able to find earlier versions of your solution or project files.
There is one other technique, and I... I hesitate to mention this. What you need is a DeLorean car from the eighties, and enough plutonium to generate 1 point 21 GigaWatts. You also need.... forget it, no, Version Control is your best bet. Or Ctrl+Z.

Holding ctrl+z for a few minutes, and using version control are the only two ways I am aware of doing that..

In case you're like me and trying to recover from what you just did, if you saved your work to OneDrive, you can find the previous version of your work by logging into OneDrive through a web browser.

Newer versions of Visual Studio should have a "Timeline" feature that shows up in your left bar. It has probably been saving past versions of your files. But I would agree with others that using Version Control (like just committing your changes to a Github repo) is probably a smart idea!

Related

How can I upgrade my Realm Swift version from 0.96 to 0.97?

Can I just replace the two old version realm frameworks to the new version ones? Or what should I do?
Yep! If you're not using a dependency manager like CocoaPods or Carthage, you just need to delete the old framework folders and copy the new ones into the same place. Xcode should be fine handling that the next time you attempt to build your project.
If you are using a dependency manager, then you just need to hit the update command in their command line tools, and it'll be taken care of automatically.
Please keep in mind that Realm 0.97 has completely removed all of its previously deprecated APIs, so if you were using any of those, you will get build errors, but they'll be very easy to fix.
I cam up with the same question and while looking around came up with a good solution. This is in addition to what TiM has pointed out. Also, a few things to keep in mind:
I upgraded from version 1.0 to 1.0.1: so there weren't many changes to the framework and commands I used in my app.
I didn't use any special or very specific commands. Mainly the queries and writes/updates of objects. Nothing very fancy. If you have very specific requirements of Realm than I suggest look into those and see if there are any special changes to how they are managed.
Now to the steps:
Remove the frameworks from the "Embedded Binaries" section by clicking the "-":
General Tab - Embedded Binaries
Remove the frameworks from the project itself by right-clicking on them and select "Delete"
Navigator - Framework Files
Now just go and do the steps for installing the frameworks as found in the documentation "realm.io/docs/swift/latest/#installation-swift-22".
I understand this question is rather old, but looking through the SO I dint find a definite answer to this.
Hope this helped!

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?

Website running .NET 3.5 cannot use feature not part of ISO-2 specs

I am getting this error a lot:
Feature '{insert feature here}' cannot be used because it is not part of the
ISO-2 C# language specification
I am working on a .NET 3.5 website that I've worked on on and off for about two years. I've never seen this error before my most recent around of updates. I'm using a decent amount of LINQ coding throughout and I get these errors related to much of the LINQ code. Based on what I've read it seems like even though I'm using .NET 3.5, for some reason it thinks I'm using 2.0. But I can't find anything that says how to fix it.
One example of a problem is that if I try to add a new item to the App_Code directory, I do not get the option to add a LINQ to SQL dbml file.
If anyone can shed some light on how exactly I would fix this, I would much appreciate it.
I was unable to locate an "Advanced" option under the build tab. I have a feeling it is probably because it is a web app. I looked through the web.config and found 2 parts that may be important. Most things referenced 3.5.0.0 or v3.5. The settings are consistent with older backups of the web.config from when there were no errors. By the way, only intellisense and things within VS2010 are giving me problems. The website is running error free.
I have completed a total uninstall and re-install of VS2010 and I'm still having the same issue. I fired up my old install of VS2008 and I am NOT having this issue there. However, I would MUCH prefer to use VS2010 on this project.
I opened the website in VS2010 on my work computer, and there are no errors reported. This is making me think that there is something on my laptop that is causing the problem. As I noted above, I completely reinstalled Visual Studio 2010 and I am still having the problem. What does this leave? I have only one extension installed in VS, and it's the same one at work and on my laptop. Also, I did not reinstall the extension after reinstalling VS, and the problem persists.
Both PC's run Win7 Ultimate. Have VS2008 and VS2010 installed. VS2010 has the same extension installed on both. On my laptop I have the full version of SQL Server 2008 installed, but only the Management Studio on my desktop (we have a server in the office). Would SS2008 have anything to do with it?
Go to your project properties, the Build tab, Advanced - that should allow you to set which version of C# you want to use. It should default to the latest version supported by the version of Visual Studio you're using, but it sounds like at some point you've switched it to ISO-2.
(That's certainly true for Windows projects and class libraries - there may be a different location in a web app. In particular, have a look in Web.config.)
If this has only started happening recently, I'd have a look through your source control history at changes to any configuration files. Also try creating a new project of the same type, and see if that has the same problem.
Jon Skeet's answer is mostly correct. The location for the update is in the "Property Pages" which I got to by right-clicking on the name of the website, clicking Property Pages, the Build item, then target framework.
The extension I use, Solution Navigator, has it's own heading for the solution. Right-clicking on it DOES NOT give me the Property Pages option. By chance I right clicked on the title of the website under the solution heading and was presented with the Property Pages option. In there was the Build tab which contained the target framework option.
Once I finally found the target framework option, it was indeed set to .NET 2.0 for some reason. I changed it to 3.5, reloaded the solution, and now it works great.
Thanks a million Jon for your help and time working with me!!

Don't see Clean solution option in Visual Studio

For one of the solutions, I don't see the Clean Solution option neither in the context menu when I right click on the solution name in the Solution Explorer nor in the Build menu. When I make any changes to the project and debug, VS never hits the break point and I get the "The breakpoint will not currently be hit. The source code is different from the original version." message. My understanding is that I need to clean the solution.
For other solutions, I do see the Clean solution and I don't have the same issue.
If you are using website project then their wont be clean solution option,it's available only with web application projects.
Finally had to create a brand new solution and add the projects from the older solution to the newly created one. Not sure what the problem was, but this helped.
I also faced the similar problem recently and this is what I came to.
I guess you are running an older code version than the one you want to debug on. Rebuild the project(s), paying attention to dependencies. Use the "Rebuild" feature.
If it's a Web application project, just clean it yourself by nuking all DLLs in the bin. Then rebuild. I assume it builds without errors?
If you're running a web site, as apposed to a web application project, you probably don't have an actual solution, or even a project file.
For a web site, you need to rebuild the website (from the build menu), or manually delete all of the dlls to accomplish the same thing.
Edit:
How are you debugging? Are you using Cassini (the built in visual studio debugger), or attaching to an IIS process?
I would also try this:
Go to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and delete the folder that has the same name as your website.
I had the same problem. Visual Studio was building my old code with debug. I opened a new instance of Visual Studio and opened my solution with it and it now works fine. No idea what happened.
You can also clean using devenv /clean SolnConfigName SolutionName in the command line environment.
Here is the reference: http://msdn.microsoft.com/en-us/vstudio/aa718635.aspx
For a website solution, just clean your web browser history and the Cache there.

Don't publish particular folder in ASP.NET

Is it possible to exclude a folder in a web project from being published? We've got some documentation and scripts that included in a particular project folder, and are added to the project, but when I do a VS publish, I don't want them to go up to the production server.
I know they shouldn't be in the project, but I thought I'd find a workaround before I try to convince the owner to modify the way he's doing things.
Old question, but I found if I mark the folder as hidden in Windows Explorer, it doesn't show/publish in your solution.
This is good for example to stop original photoshop images being included in uploads which aren't used and are big. Anything more complex though you'll probably want to write your own publish tool.
This doesn't answer your question, exactly, but my feeling is that unless you are a single developer publishing to a server, you would be better off doing builds on a dedicated workstation or server using MSBuild (or some other building and deploying solution) directly (and thereby would be able to very granularly control what goes up to production). MSBuild can not only build, but using some extensions (including open source types), it can also deploy. Microsoft has a product called MSDeploy in beta, and that might be an even better choice, but having no experience with it, I cannot say for certain.
In our situation, we have a virtual workstation as a build box, and all we have to do is double click on the batch file that starts up an MSBuild project. It labels all code using VSS, gets latest version, builds the solution, and then deploys it to both servers. We deploy exactly what we want to deploy and nothing more. We're quite happy with it.
The only downside, if it could be considered a downside, is that at least one of us had to learn how to use MSBuild. VS itself uses MSBuild.
For the files you don't want to go, loop at the properties and set the 'Copy to Output Directory' to 'Do not copy'
This option is not available for directories, however.
Can you not exclude them from the project through visual studio to stop them being published. They will the still exist in the filesystem
The only way that you can do this to my knowledge would be to exclude it from the project, do the publish, then re-include it in the project. That can be an issue.
There are probably much better ways to solve this problem but when we publish a build for our dev servers, we'll run a batch file when the build is complete to remove the un-needed folders and web.configs (so we don't override the ones that are already deployed).
According to http://www.mahingupta.com/mahingupta/blog/post/2009/12/04/AspNet-website-Exclude-folder-from-compilation.aspx you can just give the folder the "hidden" attribute in windows explorer and it won't publish. I tested this and it works for me.
Seems like a straightforward solution for quick and dirty purposes, but I don't think it will carry through our version control (mercurial).
Select all the files that should not be published.
Go to Properties
Set
Build Action -> None
Have to repeat the process for each sub-directory.

Resources