Deployment practices for .NET - c#

I have a new application i would like to deploy to a Managed Server I have recently signed up for. I would like to know what would be the best way to deploy to it. In my experience I have seen that many of the asp.net applications just push dlls to the server. How is this achieved?.
I have Tortoise SVN as my subversioning system. I have a repository on another server and usually i commit my changes and then update my release folder in the managed server but this has all the .aspx, solution and other files I belive are not needed. How can I do my set up so that I only push the dlls and when updating that only dlls are updated?.
I am not too clear on this and would like an explanation and best practices given this scenario.

I have faced similar questions before and follow the below steps every time I move the compiled files for incremental fixes in my application.
Maintain two separate copies of the solution files - Local Application and Production application
//This is very important because once you go to production environment. One copy for your local working and other copy only for deploying in the live server. This copy should be up to date with your live server copy.
Make the changes to files and compile and test the application in your local application folder/solution. Now commit only the files that you edited. SVN will take care of this. It will show you a possible "red mark" for the files which differ from the updates present in the repository. In this way you can track the pages which were modified.
Now open open your production solution folder and update the folder. This will update the files in production application folder.
Now compile and test the changes done. Verify if its issue is fixed or the changes are reflected same as the Local application copy. Now build the application and publish to a folder.
To know the modified files:
DLLs:
Go to the bin location of the folder and "order by" modified date. These are the dlls which are to be copied and replaced with in your life server.
ASPX/ASCX
a) Open SVN of production application folder. Right click and click show log. This will show all the files modified/updated with date. Select the ones last updated and note down the location.
b) Now navigate to the location in your published folder and select those files "ordered by" descending/ascending modified date of the files. Replace those files alone to your LIVE server.
Note: This is certainly not the best possible solution, but one of the general practices followed throughout the industry. There are few other plugins which can track changes and publish the relevant files to your published folder. But again ,this is applicable only if you have the source codes and application files in the same machine as of the one you are hosting the application from. Let me know if you have any question in this.

You can just use visual studio web deploy, it will automagically figure out what needs to be updated and only pushes what is necessary unless you ask it otherwise.

Related

DLLs not working after installing Visual Studio Setup Project

I have a C# project that I am creating which uses a few DLLs located in a separate folder in my project. I have added these files into the application folder on the file system viewer in the installer project.
Everything seems to work fine, it builds properly and doesn't show any big errors.
However, after I try to install my application, it is way smaller than it should be (8.24 MB compared to over 400 MB). I believe the issue arises when I try to open the Microsoft Azure Kinect camera. An error pops up when I do this saying the device could not be opened. This is strange to me because the program runs just fine in debug mode in Visual Studio, meaning the camera is plugged in properly and works.
I compared some of the DLL files from a working, older version that a consultant had made (they created an installer that works fine on my computer). The file sizes were drastically different for these DLLs.
For reference:
File Size Differences
I have tried redoing the installer, deleting and re-adding the DLLs, and overwriting the bigger files into my application after installation. I have the SDKs for the Kinect downloaded on my computer. I am also not an administrator for this computer as it is not my personal computer. Another note, the installer from the consultant works fine, however when I try to download the source code that installer came from and try to install it from there, the same issue happens.
The video the consultant used to create the installer is this: https://youtu.be/6Mfp2EXmVNI
I followed this tutorial as well, but same issue.
This is a summary of my comments above
So it looks like you are using Git Large File System (LFS). You currently only have placeholder files. With a Git LFS repo a git pull only grabs non-LFS files whilst leaving placeholder files for everything else. You need to tell Git LFS to actually download them proper.
Try:
git lfs pull
Some Git GUI clients will do this for you automatically.
OP:
...which uses a few DLLs located in a separate folder...
BTW, if these files are essentially static consider adding them to Git as non-LFS files then you can grab them like any other files in your Git repo. LFS is only "useful" if the files will be changing a reasonable number of times and then you have to ask yourself is it really worth it.
See also
git-lfs-pull(1) -- Download all Git LFS files for current ref & checkout

Getting error message unknown server tag 'dnn:ComboBox' when setting staging from production

I have copied files and database from production environment and copied to staging server, when I browsed on staging environment then getting this error message.
This most likely occurs because you're missing the referenced assemblies on the server. The DotNetNuke libraries appear to be missing.
You need to add the relevant references as CopyLocal and then redeploy.
It's a good idea to ensure that your environments are as near-identical as possible, and that if referencing third-party libraries, you're either:
Installing the libraries in the GAC across all environments and referencing from the GAC
Using copy-local references and deploying the assemblies with your code
Using something like Nuget and having your CI system resolve them prior to deployment.
Try comparing your development web.config file with staging. I guess you have a tagprefix (e.g. < add tagprefix="dnn".. />) in your development config file (under system.web -> pages -> controls) but not in staging.
This appears to be an incomplete backup/restore. Please start over. Be sure to copy all files. If they're coming from a Zip file, be sure to "unblock" the Zip file in its properties.
A good backup restore will have the following:
All files from the original location (sometimes in a zip file).
Full backup of the database.
A good restore requires the following:
Domain name to respond to.
A folder with the full file system backup copied into it.
The folder will require permissions to load all files (e.g., IIS_IUSRS and Network Service).
Full restore of the database to an accessible (local?) database with a unique user assigned to it as db_owner.
Updated web.config to reflect the new database location and user credentials (usually requires at least 1-2 updates).
Update the PortalAlias and PortalSettings tables to correctly reflect the website domain name to respond to (e.g., localhost.mysite instead of productiondomain.com).
As long as there are no typos or missed steps, this works every time.
Optional additional things that we usually do include:
Scanning for viruses.
Scanning for unexpected files (e.g., *.asp and *.php).
Updating the HostSettings to reflect a new (local SMTP) server.
Cleansing the restored database of PII.

How do you "Build" an exe that includes all the resource files like pics? Can exe be put on a web page?

I have students in high school who have created some programs using Visual Studio C#. They created some games and would like to now upload them to the web. I am pretty new to Visual Studio C#. I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on. It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place. How can I get a clean exe of their game? Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Microsoft wrote a guide on how to do exactly this. It's on their MSDN website, which is sort of like the developer back-bone for a lot of Microsoft software and documentation.
Old guide: Adding and Editing Resources (Visual C#)
Newer guide: How to: Add or Remove Resources
The gist is that the program needs to know where the files are, relative to the location of the compiled binary (in this case, an .EXE); There's several different ways to do this, depending on your level of expertise. I would suggest that you take a look at the guides above to start that journey.
there's a few ways of doing this. (Also, make sure you're creating a 'release' build when you compile).
You can include resources in your game by creating a resources file. This is something I usually do only on winforms applications etc.
If you have on-disk files you need to distribute those on-disk files along side your game. You could do this by zipping up your game.exe and the /files/images.img folder (or what ever your resources content folder is named).
If you're feeling adventurous you could create a 'deployment project' which is a project that allows you to create an installer file. This is a bit more work however you will have fine grained control over what files go where etc.
Good luck!
EXE files generally aren't self contained for video games with many resources, just add resources in an external folder and make sure the paths to the resources in their games are not absolute but relative in the local directory.
So for example:
get rid of paths like C:/Users/Bob/Desktop/Game/Images/player.png and replace with /Images/Player.png.
Also, an EXE generally doesn't run client side on webpages, it is possible but difficult. Things such as Flash are made for this sort of issue. I'd say make the webpage a place where they can download their games. Github has a nice way to do free websites called gh-pages. OFC, you could host one yourself but that would require a lot of setup work.
Like Monza said, you can zip up the files for download. Or, you could create an installer if you wanted to be really ambitious.
I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on.
That is correct, given that the other machine has the necessary .NET framework version installed AND any other resources like .dll files and config files are also present. When the application is ready for release, you can set the Build options in the project properties to Release, and then when you build all the files needed for distribution will be in the bin\Release folder.
It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place.
This may depend on how the application was written. If resources like pictures are embedded in the assembly then those files will not be needed to run on another machine. If the application is using hard coded paths for the image resources in the source code, then the application will likely break if the necessary files aren't present when the .exe is executed.
Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Yes - you could upload the .exe to a file server to make available for a download, but you would not be able to run it within a browser over the web. I would recommend zipping up the .exe and other files needed and hosting the .zip file on the web server for download; browsers may give a warning or block downloading an .exe .
Hope this explains it a little bit for you.

ASP.NET recompiles on every request

I have a ASP.NET Webforms compiled site that works flawlessly on my local machine. As soon as the site is pushed up to the live servers (A bank of 10 servers running IIS8 on windows server 2012) the site will recompile on every request.
If I go to the temporary ASP.NET files directory there are App_Web dlls for all the user controls in the site along with .delete files for all the binaries which is what I think is causing the appdomain to restart every time.
App_Web_course.aspx.cdcab7d2.ijbbuqi7.dll
App_Web_course.aspx.cdcab7d2.ijbbuqi7.dll.delete
It does occasionally run OK on some of servers and when I look at the temp .NET files on those servers the .delete files aren't there.
I'm pulling my hair out, In 17 years of development, I've never seen this before and there seems to be no rhyme or reason for it.
Update: If anyone else experiences this, please check my answer below for my resolution.
I have an update and solution to the problem.
At the time of the original post, I had left out that the files were located on an SMB network share. This has been the cause of this constant recompiling due to the fcnMode of ASP.NET.
Process Monitor showed thousands of requests through w3wp.exe for "FileChangeNotify" which when hitting a critical directory such as "bin" it would cause a recompilation and application restart.
Luckily there is a single line fix for this. In the web.config(s) of your project, alter the following line to include the following attribute:
<httpRuntime fcnMode="Disabled" />
This will stop ASP.NET from scanning your network directory for constant file changes.
Possible reasons that cause recompile.
You update the web.config
You create/delete the app_offline.htm file on the root.
You create/modify any .aspx or .aspx.cs file
You create/modify files on App_Code folder
You have left some upload folder unattended and users upload aspx files.
You time/date on the computer is wrong (back some years)
You can use the Process Monitor to see what happening from all that if you can not locate it on code or don't know what other libraries do.

Azure Web Deploy publishing old version of MVC sites .dll

I deploy my MVC site via a web publish within VS 2013 to an Azure location. I have published many times without issue from the same machine and IP address, but yesterday it stopped working.
The publish is placing an old version of my projects .dll in the bin folder on the site. This version no longer exists on my machine, it isn't the projects current Git state (and has never been the current Git state) and is not the version in my Release, Debug or Demo compiled folder. I don't know where it's coming from.
So when I publish, I get errors relating to the database changes because the model behind my context has changed since this old version.
So currently when I publish I have to FTP into my site and replace the WebPortal.dll file with the one in my machines bin folder, and the the site works fine.
What could be causing it to revert to this old .dll and where is it coming from? Have I somehow excluded my changes past a certain point from the publish?
Note - My views are publishing absolutely fine, it is just the .dll that should contain the current compilation of Models, Controllers etc., but instead contains an old version missing loads of stuff.
JK
There might be an old version of your dll on the server that is not being overwritten during publish. Have you tried checking "Remove additional files at destination" the the settings section of the Publish dialog. That should remove all the files from your target location except the one you publish.
If you are still having a problem after that try publishing to your local file system so you can see exactly what publish is sending to your server.
Update:
Steps to publish web application to file system.
right click on your project in the solution explorer menu and select Publish.
In the profile section of the Publish Web menu select Custom publish type, click next.
Select file system in the Publish method drop-down. You should see the target location text box where you can specify your folder.
Continue with the rest of the publish steps with you usual settings and click publish.
Double check that your Build (Menu) > Configuration Manager > Build Configuration for Release has the tick next to Build for the WebPortal.DLL. If it isn't set to build then it would use an older version.
I had the same problem. Goodness knows where the old dll is coming from but in the end I up-versioned the library to a higher number and it seemed to cure it. I suspect the GAC or temporary files might be part of the problem although I can't find my library there.

Categories