MVC Web Role Post Build Event - azure

I'm trying to copy two files to the bin directory to a Windows Azure Cloud Services deployement, I added the below Post-Build event script to the MVCWebRoleCore project properties:
copy /Y "$(ProjectDir)lib\SqlServerSpatial.dll" "$(TargetDir)SqlServerSpatial.dll"
copy /Y "$(ProjectDir)lib\SqlServerSpatial110.dll" "$(TargetDir)SqlServerSpatial110.dll"
Everything looks good locally and the two files are copied, but on Windows Azure the files are not there in the bin directory, (I checked the cloud deployment using RDC to make sure), What am I doing wrong?
Thanks

When you deploy, it doesn't care what files are in your BIN folder. It cares about what files your CSPROJ project file specifies as part of the project deployment. If these are dependencies in your References list, just make sure Copy Local is set to True and they'll be deployed.

Related

Azure Continuous Deployment ignoring image files

I set up continuous deployment for my app service on Azure. When I push changes to my repo (on Azure Devops), Azure deploys my changes except for the image files. It's like it's ignoring .jpg files but pushing the rest. I also confirmed the image files to exist in my repository on the server and that Azure's continuous deployment feature tried to deploy.
Go to Solution Explorer and find image file(s) there.
Right-click on the file and open properties.
Set "Copy to Output Directory" to "Copy if newer".
Build project and make sure that images has been copied
I found out my .csproj ignored the file. I just right clicked the file in Visual Studio and changed the properties to not exclude the file.

Azure DevOps - Clean up old releases on on-premise server?

I have a pipeline that deploys code to an IIS folder on an on-premise server. I'm trying to figure out how to best delete old release folders. I'm not seeing anything obvious within DevOps.
Is there a native way of doing this? Or should I roll my own PowerShell script to delete old releases?
Is there a native way of doing this?
Yes, of course there is.
Open your deploy task, go Advanced Deployment Options and then enable the option Remove Additional Files at Destination
Noted: This "delete" operation I mentioned is not mean that clear all the files in local IIS folder. It just delete the files at the destination where there's no corresponding file in the package which is being deployed.
In one word, for some files which same with previous, it will be override as the latest files. And, for any left over files from a previous deployment that are no longer required, they will be deleted.
If you do not trust this option and want to clear the previous files completely, you can also add the Powershell task before IIS manage task and run delete script.
Here is the sample script to delete local files:
Remove-Item -Path "D:\Websites2\*"
You can replace "D:\Websites2\*" as your local website file path.

Azure deployment from GitLab is replacing App_Data folder

I have an app service in Azure and I have connected it with my source control on GitLab, everything works fine except one thing. When I deploy from Visual Studio I can tell that App_Data should not be replaced and it works. However, deploying from GitLab (I used this tutorial https://christianliebel.com/2016/05/auto-deploying-to-azure-app-services-from-gitlab/) just replaces all the files with what I have in source control, effectively removing customers data from App_Data.
I presume that this is just simple FTP replace (as I have to run my migrations on App_Start), yet is there a way how to not replace App_Data folder on the app service when deploying from gitlab? Having synchronized App_Data with source control is not acceptable.
Thank you
I have resolved the issue by downloading deployment.zip from AppService's Kudu.
Then I edited downloaded deployment.cmd so that KuduSync ignores App_Data.
Then I inserted the modified deployment.cmd and .deployment file to the root of my git folder.

How to preserve user-uploaded files on WebDeploy in Azure

In the Azure release definition I publish the build artifact to the UAT WebApp using Azure web deploy. However this deletes any previously user-uploaded files (e.g. images).
How can I release to UAT and preserve the user uploaded files?
Do I somehow need to perform the equivalent of extracting the .zip file over the existing files rather than replacing the entire website directory with the contents of the .zip?
You can add the following MSBuild property to your build
/p:SkipExtraFilesOnServer=true
OR add the MSDeploy provider flag:
-enableRule:DoNotDelete
https://dotnetcatch.com/2016/02/01/webdeploymsdeploy-quick-tip-keep-existing-files-during-deployment/
Did you try to use the -skip:Directory option to excluse the directory where the images are uploaded ? See: https://technet.microsoft.com/en-us/library/dd569089(WS.10).aspx

Azure deploy missing XML doc files from deployment target

I have a solution. 2 projects within the solution produce XML documentation, that I need to copy to the bin folder web root when I deploy to azure.
Locally, I notice that when I build my solution, those 2 XML files get copied with the DLL into my web/bin folder. When I run my un-modified deploy.cmd file locally, I also notice that kudosync picks those up and hapilly puts them into my artifacts/wwwroot/bin folder.
But - when I deploy to azure by pushing to github, the local deployment temp folder on azure doesn't contain the XML files, and thus they don't get picked up. I added some post-build "DIR" commands to the deploy.cmd file to see what is going on, and the XML files just aren't there in the %DEPLOYMENT_TEMP%\bin\ folder.
Anyone know what's going on here?
Aha - it's because when you build from MSBUILD, it doesn't generate the XML docs for the related projects. I was getting them locally because I'd at some point built from VS, which generated them.

Resources