简体   繁体   中英

How to determine affected files when building a single webpage in a visual studio project in order to update website with just that page?

Updating a webpage in an inherited VS2017 C# MVC project. Cannot just copy entire rebuilt result because I don't have the latest codebase which matches what is in production (yet), and need to add a new page to existing website. Only want to promote this single page/.dll into existing production.

Background: I inherited huge precompiled C# website code from a website vendor (we built it, we got paid, now it's yours) which includes 6 projects in the solution and I'm not familiar with MVC-think. The first time I added a new webpage to the project, did a build, dropped to a prompt and sorted my local (I publish to my local drive and then robocopy the files to the server manually) TFS publish /bin directory by datetime and found the single .dll file that had changed. Copied that plus the source page (stub) onto the production website.

It actually "worked"...but gave me a server error 500 (not helpful) yet all other pages load and work fine, so that means I'm on the right track I think...so I went back in, added some debugging code to the page, did another build, but now there are like 10 .dll files that changed?! I heard that REbuild causes all files to get updated regardless of changes so I've been using Build only.

How to reliably tell which files I need to copy after a build? Can I somehow tell VS to only rebuild that single webpage in the project?

So after a lot of trial and error I've found that only certain files can be done like this. The code pages in question need to have no impact on any other pages in the project or other dependencies other than very specific assemblies that are straightforward and only used in that particular page.

In my specific example I was adding an ASP.Net page of code to an existing C# project. My page required an external .dll assembly to work but none of the other code in any other projects were impacted by that. I also ran into a 32-bit vs 64-bit issue where the assembly had to be the 32-bit one in visual studio or the project wouldn't compiler, but the runtime assembly had to be the 64-bit one in order to run on the website, so I have to manually copy that over. Ugh.

So I found I can do a complete Build of the project, then do a Publish to precompile the entire solution. Then I look in the resulting /bin directory on my local machine and find the relevant *.compiled file which starts with the filename of my code page. In that text file is a line that reads assembly="App_Web_4wfba3zi" or similar. That tells you which .dll the project needs to run that precompiled webpage.

I copy both the .compiled and .dll files into the production website /bin directory (remembering to leave the stub file in the website) and I'm golden! This has certainly been a learning experience...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM