This repository has been archived by the owner on Feb 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
MSDeploy Publish
Vijay Ramakrishnan edited this page Feb 22, 2018
·
2 revisions
Using MsBuild (with the default profile)
msbuild WebApplication.csproj /p:DeployOnBuild=true /p:WebPublishMethod=MSDeploy /p:MSDeployServiceURL=<msdeployUrl> /p:DeployIisAppPath=<IISSiteName> /p:UserName=<username> /p:Password=<DeploymentPassword> /p:PublishProfile=Default
Using dotnet (with the default profile)
dotnet publish WebApplication.csproj /p:WebPublishMethod=MSDeploy /p:MSDeployServiceURL=<msdeployUrl> /p:DeployIisAppPath=<IISSiteName> /p:UserName=<username> /p:Password=<DeploymentPassword> /p:PublishProfile=Default
Profile can be added to the following location in the project /Properties/PublishProfiles/<MsDeployProfile.pubxml>. MsDeploy Publish profile samples are available below:
Using MsBuild (with a profile)
msbuild WebApplication.csproj /p:DeployOnBuild=true /p:PublishProfile=<MsDeployProfile> /p:Password=<DeploymentPassword>
Using dotnet (with a profile)
dotnet publish WebApplication.csproj /p:PublishProfile=<MsDeployProfile> /p:Password=<DeploymentPassword>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://webappwithdb.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<MSDeployServiceURL>webappwithdb.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>webappwithdb</DeployIisAppPath>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>$vramakwebappwithdb</UserName>
<Password>DeployPassword</Password>
</PropertyGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://webappwithdb.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<MSDeployServiceURL>webappwithdb.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>webappwithdb</DeployIisAppPath>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>$vramakwebappwithdb</UserName>
<Password>DeployPassword</Password>
</PropertyGroup>
<ItemGroup>
<DestinationConnectionStrings Include="ShoppingCartConnection">
<Value>Data Source=tcp:dbserver.database.windows.net,1433;Initial Catalog=shoppingcartdbdb_db;User Id=appUser@dbserver;Password=password</Value>
</DestinationConnectionStrings>
</ItemGroup>
<ItemGroup>
<EFMigrations Include="ShoppingCartContext">
<Value>Data Source=tcp:dbserver.database.windows.net,1433;Initial Catalog=shoppingcartdbdb_db;User Id=efMigrationUser@dbserver;Password=password</Value>
</EFMigrations>
</ItemGroup>
</Project>
Sample to prevent files from being published:
<ItemGroup>
<Content Update="wwwroot/images/*.svg" CopyToPublishDirectory="Never" />
</ItemGroup>
Sample to skip specific folders and files during Web Deploy Publish:
<ItemGroup>
<MsDeploySkipRules Include="CustomSkipFolder1">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>wwwroot</AbsolutePath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="CustomSkipFolder2">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>wwwroot\\Content$</AbsolutePath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="CustomSkipFile1">
<ObjectName>filePath</ObjectName>
<AbsolutePath>Views\\Home\\About.cshtml</AbsolutePath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="CustomSkipFile2">
<ObjectName>filePath</ObjectName>
<AbsolutePath>Views\\Home\\About2.cshtml</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>