Must bin/roslyn be published every time? - c#

I'm publishing over webDav to webserver; the site is both classic asp and new c# aspx.
Currently it is only two pages, but the majority of the time is spent uploading bin/roslyn.
The time of the files in bin/roslyn changes to the time of publish.
Is this upload nessecary every time; does the files really change?
I'm not asking if bin/roslyn can be removed.
Is there a way to just upload the changed files?
I'm uploading over 4G network, while it is not exactly slow, it's not wirespeed either.
I don't uplode the entire website; there are a lot of old .asp and images I haven't pulled to my workstation, so I don't delete the existing files first.
Copying all files to temporary location below for package/publish:
obj\Release\Package\PackageTmp.
Publishing folder /...
Publishing folder bin...
Publishing folder bin/roslyn...
Publishing folder xml...
Web App was published successfully file:///Y:/
I'm not sure how to get a list of all files, but I'll write a few names:
Microsoft.CodeAnalysis.VisualBasic.dll
Microsoft.CodeAnalysis.CSharp.dll
Microsoft.CodeAnalysis.dll
Microsoft.DiaSymReader.Native.amd64.dll
This is in descending size; already this is about 10MB.

I have not used webDav before, but it seems like work the same as ftp publish.
If you want to publish only part which have changed, there is two way:
use web deploy
publish to local file then chose only upload the part has changed
use web deploy
there is article of how to set up web deploy at microsoft docs
https://learn.microsoft.com/en-us/iis/install/installing-publishing-technologies/installing-and-configuring-web-deploy-on-iis-80-or-later
essentially install web deploy at iis, then when publishing in VS, chose web deploy
deploy to local folder then upload change part
in VS, publish to local folder, then manually upload file which have changed (if you use version control, who wouldn't, you should be able to tell which files has changed)

Related

Website on IIS Errors When Listing Directories

I have a VPS (Cloud Server) and I have Visual Studio, IIS, SQL... all those nice things installed. I am also sometimes doing development on this VPS.
This website is basically a simple file manager. When it loads, it lists files and folders that resides in the App_Data folder. This said, I am using the App_Data as my "root/home/topmost-directory" for the file manager.
The reason I am putting them in the App_Data folder is because I don't want users to just go like this: www.mywebsite.com/ROOT/[gets a list of files].
Instead, if they try to go: www.mywebsite.com/App_Data/[tries to get list], IIS will block them with a nice error (because IIS blocks access to that folder).
So, the website accesses the structure in the App_Data folder via code behind. This is how the website navigates. It can download, upload, move files around, rename... delete... everything right to/inside the App_Data folder.
The only problem is, this only works when I run the website in Visual Studio and run my tests, testing the website, debugging, etc. The moment I publish (via File System in Visual Studio) the website to the directory: "C:/inetpub/Sites/[WebsiteFolder]", and navigates to the website's URL, the website does not work any more. It loads, but it does not get the file structure in the App_Data folder any more, it cannot create new folders, cannot rename them...
This website works fine when I upload it via FTP to another webs space that is hosted somewhere else at another hosting company (which is shared hosting).
So I guess (my best guess) the IIS on my VPS does not allow this kind of access. And I have been trying to find settings on IIS somewhere that would/could allow this.
I have enabled directory browsing, but that's probably the only thing I can think of other than making sure the directory is accessible (readable/writable).
Do you perhaps know what else I can try?
Ohkay, so this was a very silly mistake - but that's how we learn!
The App_Data folder did not have any other files or folders inside of it.
And as we know, ASP.NET does not publish empty directories. This means those empty folders never existed once I published the website.
There are 3 ways to fix this that I know of at the moment:
If your solution has a publish profile (so that you can publish the site), you can right click the empty folder in Visual Studio, and say Publish [FolderName] eg:
You can just create an empty file in that directory, and publish your whole website again. Because the folder is not empty any more, it publishes with the rest of the website.
Just manually create the folder on your hosting space.
Thanx for everyone's input!
Greatly appreciated!

Avoid deleting files on Azure Cloud Service publish

I'm hosting my ASP.NET MVC applications as Azure Cloud Service.
I encountered a problem deleting pictures, which uploaded by user, after new deployment.
Uploaded pictures are saving into the custom special folder WebProject/UserFiles/MedicalCenterImages
Below I've provided my project folder structure.
I've found and investigated several questions related to my
Avoid deleting folder on Web Publish
MSDeploy skip rules when using MSBuild PublishProfile with Visual Studio 2012
and figure out, that I should to add a SkipDelete rule on the .csproj file.
<Target Name="AddCustomSkipRules">
<Message Text="Adding Custom Skip Rules" />
<ItemGroup>
<MsDeploySkipRules Include="SkipUserFilesFolder">
<SkipAction>Delete</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>UserFiles</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>
</Target>
but I don't fully understand which file I should to edit in my case? (MaxPatient.Web.csproj or MaxPatientCloudService.ccproj or any another file)
I always publishing my MaxPatientCloudService project.
I will be grateful for any help.
Thanks :)
Azure Cloud Service deployments typically (staging slot with a VIP swap to prod slot) create new virtual machines (VMs). You can only plan on content files in the actual MVC project to get deployed to the new VMs. User uploads won't survive a deployment. You need to store uploaded files in Azure BLOBs, database or use an Azure website instead of a Cloud Service.
Whenever you publish to Azure Cloud Service, new VM is created. If I want Azure not to delete a blank folder, I normally add a dummy file inside the folder.
Ideally, you want to punish to Staging. Then SWAP Staging with Production so that you can minimize the downtime of our site.
In addition, you need at least two instances in Azure Cloud Service. One instance cannot access folder inside other instances.
Uploaded pictures are saving into the custom special folder
WebProject/UserFiles/MedicalCenterImages
For scenario, you need to save customer images in Blob Storage (or SQL Azure), so that all instances can read/write the image.
Note: when Azure recycles an instance (whatever reason), it creates a new VM from original uploaded package. Therefore, we should never save data inside the web server's folders.
Go to Publish Settings -> Expand File Publish Options -> And Untick the box that says remove additional files at destination.
I am not sure if this works for continuous deployment but a solution with manual deployment from VS is to put the server files you want to keep in the App_Data folder.
The standard publish settings for VS / Azure allow you to:
"Remove additional files at destination"
and
"Exclude files in the App_Data folder"
This means that you can clear redundant project files in the project without affecting files and data that is specific in the live application
A possible downside will be restriction of public access to App_Data and use of the App_Data folder for general storage purposes - see also this post about that issue.
Images that are in App_Data folder not shown in browser

Deployment practices for .NET

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.

How can I use the ExportLogic command in EWL to deploy an application?

What exactly are the steps to take after running ExportLogic in the Package Manager Console? Does this do anything for updating the database on the server?
To deploy an EWL system using ExportLogic, the first step is to do a release build of your solution.
When that's done, run ExportLogic, which creates a Logic Packages folder in your solution's folder. Logic Packages will contain:
Server Side Logic folder - contains the files you need to put on the server for your system to run correctly, minus installation-specific config files
Client Side Application folder (if your system contains a client-side app) - contains the files needed to correctly run your system's client-side app, minus installation-specific config files
Copy the contents of Server Side Logic to your server, then create an Installation folder inside the Configuration folder and put your installation-specific config files in it.
If your system has a database, execute the portion of Configuration\Database Updates.sql that has not already been executed against your live database.
Finally, for each web application folder you copied to the server, create an IIS web site or virtual directory pointing to it.
If you're interested in automating some/all of these steps, there are APIs within EWL that may help.

Prevent delete user generated content on visual studio 2010 publish

I have an application that stores images uploaded by user. Those images goes to content/images/upload. Problem is that if i published without the skip extra files on destination, all user uploaded content gets deleted. Im pretty sure im doing it wrongly, which would be the best approach for this situation ?
im worried about losing user generated content this way misconfiguring an option in publish.
One approach I've used is to move the physical path of the "upload" older outside the application folder structure. I'd use an IIS virtual directory to mount the folder to the application. For example, if the folder structure currently looks like this:
c:\inetpub\
wwwroot\
content\
images\
upload\
You might change it to this:
c:\inetpub
upload\ <-- must be manually created on the web server
wwwroot\
content\
images\
You'd remove the upload folder from the web application in Visual Studio. Log into the webserver and create the folder under inetpub (could go anywhere, really). Then go into IIS manager and create a virtual directory called upload that points to the c:\inetpub\upload folder.
The upload folder is no longer part of the Visual Studio project so the "publish" feature won't touch it.

Categories