0

I keep running into an annoying problem with Visual Studio. I make a change to a source code file (.cshtml) and then I publish it, run it, and step through parts to debug it. (it steps through the published file, not the file from the folder where the solution is contained on my local drive)

I find an error and make a change to what I think is the file from the solution folder, but it's actually the file from the published folder instead. So now I have 2 .cshtml files open in Visual Studio with the same name, where the incorrect/published file has all my new changes. I then go to check into TFS and there is nothing to check in and nothing to save in VS. Sometimes I mistakenly close the published file and loose my new changes because I click the save all button in VS and everything gets saved except the changes from the published folder! Which doesn't show any changes!

Is there any way to avoid opening the published file in VS and always work from the repo'd file so that I never mistakenly close the published file with changes in them and then loose those changes???

FYI - I debug by attaching to a IISWorkerProcess and basically debug remotely, not on the machine with visual studio.

chuckd
  • 13,460
  • 29
  • 152
  • 331
  • Can you share more information about how you debug your app remotely? Is it the ASP.NET app debugging? https://msdn.microsoft.com/en-us/library/mt621540.aspx and https://msdn.microsoft.com/en-us/library/b00hf3c0.aspx – Jack Zhai Oct 16 '16 at 05:17
  • We publish using the file system method. Then I get a list of the threads running and attach to that thread. – chuckd Oct 16 '16 at 08:03
  • Can you share me a screen shot about the real solution explorer/code Editor window which has two cshtml files? To edit a file, you could view it in solution explorer window, and then open the file. Or you could view the property of the file, so you could see the real path which was used to save it. Not very sure that whether you mean that you open two cshtml files in the code Editor window, but if so, you could close them and re-open the one you want to edit in the solution explorer window. – Jack Zhai Oct 17 '16 at 02:40
  • Do you publish the solution to a local folder like this document? http://tutlane.com/tutorial/aspnet-mvc/asp-net-mvc-publish-with-file-system, or you publish the project to the same folder as your previous local solution. – Jack Zhai Oct 17 '16 at 02:41
  • yes, the publish method is 'File System' which moves all files needed to run the site into a specified folder. – chuckd Oct 17 '16 at 18:37
  • To understanding this issue better, would you please share a screen shot? After you publish it, what steps did you do? My understanding is that the solution explorer window just has your previous local solution after you publish it, why you open two .cshtml files in your previous project using the same VS window? Maybe open a new VS window or just check the file's path under the property like my previous suggestion. Sorry for that I couldn't really repro this issue without detailed steps even if I could publish a web project in my side. – Jack Zhai Oct 18 '16 at 01:23

0 Answers0