I want to perform a post-build step to copy some files into a website folder using MSDeploy.
Eventually I'll be doing this to a remote location (specifying computerName, userName switches etc.), but for now I'm running it locally:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-AllowUntrusted -verb:sync
-source:dirPath="D:\files_to_copy"
-dest:iisApp="My Website Name"
This works, but it removes all contents of the website folder and replaces them with the contents of "D:\files_to_copy" (as you might expect!). So I was wondering how I use this simply copy to a subfolder within the site?
I've tried -dest:iisApp="My Website Name/my_subfolder" but this just creates a new IIS app called "my_subfolder" nested within the existing IIS app.
There are providers other than iisApp, maybe dirPath is the one you want for -dest aswell?:
dirPath: The dirPath provider synchronizes directory content.
filePath: The filePath provider synchronizes individual files.
iisApp: The iisApp provider synchronizes directory content to a folder and marks the folder as an application.
contentPath: The contentPath provider synchronizes Web site content.
Anders's answer above provides the correct information, but the full code I used to successfully carry this out is as follows:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-AllowUntrusted -verb:sync
-source:contentPath="D:\files_to_copy"
-dest:contentPath="My Website Name\my_new_folder"
Adding a single file to the root of the site (for example robots.txt) can be done using the following:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-AllowUntrusted -verb:sync
-source:contentPath="D:\my_folder\robots.txt"
-dest:contentPath="My Website Name\robots.txt"
Hopefully this is a useful example for others in the future.
Related
I have a git repo with a website that has the following structure:
repo_root:
- what_a_nice_day_it_is_today.txt
reference
- countries.txt
docs
- foo.txt
src
- index.html
content
- index.css
scripts
- index.js
I have created an Azure App Service using the Web App template for my web application. In the Deployment Center, I have chosen to deploy from my GitHub repo and have chosen Kudu as the build server.
How do I get Kudu to not copy anything other than the contents of the src folder (and its subfolders) when deploying my web app?
That is, I want it to leave out the docs folder and the reference folder and any file that's in the repo_root but not in the src folder, which, in this example is the what_a_nice_day_it_is_today.txt file.
Define SCM_TARGET_PATH and PROJECT env accordingly. See https://github.com/projectkudu/kudu/wiki/Deploying-inplace-and-without-repository.
I've configured TeamCity for build and deploy IIS app.
Everything works fine. Here is my command line param:
-verb:sync -source:package="webapi-%dep.xxx.build.counter%.zip"
-dest:contentpath="C:\inetpub\wwwroot\test2.com\bin",computerName="www",userName="uuu",password="ccc",includeAcls="False"
-AllowUntrusted -verbose
So, artifacts zip file should extract files to C:\inetpub\wwwroot\test2.com\bin folder. In bin folder i have a lot of xml and config files (zip file dont include this files). In every deploy it delete bin folder and extract zip files.
How can I skip deleting? I just need publish with replace what i have in archive without deleting another files?
Thanks for help
add one more parameter:
-enableRule:DoNotDeleteRule
according to doc:
In a sync operation, blocks deletions of files on the destination computer that do not exist on the source computer. This rule applies to the contentPath, dirPath, and filePath providers. This rule is disabled by default.
I am deploying my ASP .Net Core 2.0 app to my remote server using FTP. Remote Server is using IIS 8. When I publish my app, I get the following error.
Unable to add 'Project.dll' to the Web site. The process cannot access the file because it is being used by another process (550).
I been able to bypass this by manually creating an app_offline.htm first on the publish directory, and then publishing my app via Visual Studio 2017.
I was wondering, is there an easier way of doing this? or is there an easy way I can script this, so that app_offline gets created automatically before publish? and then deleted after publish?
Anyone that's curious, I gave up depending on VS to publish my .NET Core project. I'm now using WinSCP and _PublishToWeb.bat script I created to accomplish the task.
I first created a file called _app.offline.htm on root directory my publish folder. Then when I need to publish, I run the script below.
This script does the following:
1. Builds the .NET Core project to a specific folder, let's call it "_dist" folder.
2. Connects to my ftp server/publish folder and renames "_app_offline.html" to "app_offline.html", so that the server goes offline.
3. Synchronizes _dist folder with publish folder.
4. When done, changes "app_offline.htm" to "_app_offline.html", so the website is restarted.
_PublishToWeb.bat
echo off
echo Publishing to ProjectName (Optional)
set ProjectRemoteFolder=RemoteFolderName
set ConnectionString=ftp://username:password#serverIp:serverPort
set WinSCP="path to WinSCP.com"
set ProjectDistPath="a folder where dotnet publish will build the project to"
set WebAppProject="path of the project. dotnet publish will run here"
rem Build project and put it in to distribution folder
cd %WebAppProject%
dotnet publish -c Release -o %ProjectDistPath%
rem Connect to FTP and synchronize folder
%WinSCP% /command "open %ConnectionString%/%ProjectRemoteFolder%/" "mv _app_offline.htm app_offline.htm" "synchronize remote %ProjectDistPath%" "mv app_offline.htm _app_offline.htm" "exit"
rem pause
I'm sure there are better solutions out there, but this has been working well for me so far.
I have a problem related to creating msdeploy package for deploying to azure web app.
I run msdeploy -verb:sync -source:contentPath="C:\inetpub\wwwroot\<SiteName>" -dest:package=test.zip And after investigating package i found that it contains a full hierarchy of folders eg: \Content\C_C\inetpub\wwwroot\<SiteName>\ and when i am trying to deploy this package to azure a have an exception because i don't have such permissions.
Question: how to remove path from content folder so my archive will looks like \Content\<SiteName>?
After a day of investigation i figure out how to do this:
$msDeployPackageCommand = "$MsDeployExePath
-source:iisApp=$PathToApplication
-dest:package=$ZipCreationPath
-verb:sync
-enableLink:contentLibExtension
-replace:match=$ReplacePathToApplication,replace=$replaceWith
-retryAttempts:2
-disablerule:BackupRule
-declareParam:name='PackageManagementService',kind='ProviderPath',scope='IisApp',match=$ReplacePathToApplication,defaultValue=$replaceWith";
This works fine.
I am using msdeploy.exe for deploying my project to remote iis site using below command
msdeploy.exe -source:iisApp="D:\publish" -dest:iisApp="test-site",ComputerName="https://url:8172/msdeploy.axd?site=test-site",UserName="u",Password="p",IncludeAcls='False',AuthType='Basic' -verb:sync -enablerule:AppOffline -enableRule:DoNotDeleteRule -retryAttempts:20 -allowUntrusted='True'
But it is always uploading each an every file during deployment.
Is there any way so that i can upload only changed files using msdeploy.exe?
Solved using -useChecksum paremeter