I am using the post here to deploy MVC5 application to IIS 8. In IIS i have a web site "Default Web Site" which is pointed to physical location "C:\Inetpub\wwwroot\mywebsite"
My build file look like below
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<ProjectFile Condition=" '$(ProjectFile)' == '' ">.\UI\$(ProjectName)\$(ProjectName).csproj</ProjectFile>
<DeployServiceUrl Condition=" '$(DeployServiceUrl)' == '' ">http://localhost</DeployServiceUrl>
</PropertyGroup>
<Target Name="VerifyProperties">
<!-- Verify that we have values for all required properties -->
<Error Condition=" '$(ProjectName)' == '' " Text="ProjectName is required." />
</Target>
<Target Name="Build" DependsOnTargets="VerifyProperties">
<!-- Deploy using windows authentication -->
<MSBuild Projects="$(ProjectFile)"
Properties="Configuration=$(Configuration);
MvcBuildViews=False;
DeployOnBuild=true;
DeployTarget=MSDeployPublish;
CreatePackageOnPublish=True;
AllowUntrustedCertificate=True;
MSDeployPublishMethod=RemoteAgent;
MsDeployServiceUrl=$(DeployServiceUrl);
SkipExtraFilesOnServer=True;
UserName=;
Password=;"
ContinueOnError="false" />
</Target>
</Project>
I'm running the following command to build & deploy
msbuild build.xml /p:Configuration=Release;ProjectName=MyProjectName;DeployServiceUrl=http://localhost
The command builds the project and deploys the project. However it is not deploying the project directly under "Default Web Site" instead its creating a new application under "Default Web Site" with the name "MyProjectName_deploy" and this application is pointing to new physical location. "C:\inetpub\wwwroot\mywebsite\MyProjectName_deploy"
I want the code to deploy directly to C:\inetpub\wwwroot\mywebsite where "Default Web Site" is pointing.
Add the following to your build file:
<PropertyGroup>
<DeployIisAppPath>Default Web Site</DeployIisAppPath>
</PropertyGroup>
Related details -
https://dotnetcatch.com/2016/03/03/simple-service-versioning-with-webdeploy/
Related
Here i'm trying to automate publish the package for a web application to publish IIS on a remote server.
Following things are done to make the package.
Publish.proj.xml file:
<Project ToolsVersion="4.0" DefaultTargets="Publish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectSolutionFile>Test.sln</ProjectSolutionFile>
<Configuration>Release</Configuration>
</PropertyGroup>
<ItemGroup>
<ProjectToBuild Include="$(ProjectSolutionFile)">
<Properties>DeployOnBuild=true;Configuration=$(Configuration)</Properties>
</ProjectToBuild>
</ItemGroup>
<Target Name="Publish">
<MSBuild Projects="#(ProjectToBuild)"/>
</Target>
</Project>
If i pass this Publish.proj.xml file to msbuild. it'll build the solution and will create the package with below included things,
1. PackageTmp (folder)
2. Test.deploy.cmd
3. Test.deploy.SetParameters.xml
4. Test.SourceManifest.xml
5. Test.zip
Test.SetParameters.xml
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="Default Web Site/Test_deploy" />
</parameters>
Test.SourceManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
<IisApp path="C:\Release\Package\PackageTmp" managedRuntimeVersion="v4.0" />
<setAcl path="C:\Release\Package\PackageTmp" setAclResourceType="Directory" />
<setAcl path="C:\Release\Package\PackageTmp" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>
Now, i'm trying to install this package in a remote server to publish the package using below command,
SalesCatalogue.deploy.cmd /y /M:https://RemoteServer:8172/MSDeploy.axd /u:"Test" /p:Test123 -allowUntrusted /A:basic
It has created new virtual directory in IIS under Default Web Site->Test_deploy and package files are deployed in C:\inetpub\wwwroot\Test_deploy folder.
My requirement is, Virtual directory name, applicatio Pool, destination physical deployment path are should be configurable. So that I can provide name whatever for virtual directory, can select desire application pool and can deploy in different path if required.
How can i achieve this? Any one can suggest me.
Thanks in advance.
I want to build a *.appxbundle for a Windows 8.1 JavaScript app which contains the x86 AND x64 appx.
This is working fine on Visual Studio 2013. I right click on the project and choose Store->Create app packages and then pick both architectures.
However I can't get it working on MSBuild. My msbuild statement looks like this:
msbuild MyProj.Win81.jsproj /property:Configuration=Release;Platform=x64;AppxBundle=Always /target:Clean,Rebuild,Publish
My MyProj.Win81.jsproj looks like this (shortened a bit):
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
</ItemGroup>
<Import Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0'">
<VisualStudioVersion>12.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
<PropertyGroup>
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
<RequiredPlatformVersion>8.1</RequiredPlatformVersion>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="package.win81.store.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
</Project>
MSBuild will always generate a appxbundle which only includes the x64 architecture. This might be because I explicitly set Platform=x64, although AppxBundlePlatforms defines both. If I leave out the Platform parameter I run into a error:
error APPX3104: You cannot create an app bundle when building for platform 'AnyCPU' which is not included in the list of platforms selected for producting app bundle. Set platform to a one of following values: x86;x64.
What am I missing?
// edit: here a screenshot of VS2013 appxbundle creation and updated project configuration of jsproj file
I'm trying to build Visual Studio project from .msbuild file. The idea is to do some things before the build, then execute build of .sln from the same place.
Something like this:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="BuildClient" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Tools>$(MSBuildProjectDirectory)\tools</Tools>
<NugetExe>$(Tools)\nuget\nuget.exe</NugetExe>
<ClientFolder>$(MSBuildProjectDirectory)\src\Client</ClientFolder>
<ClientSolution>$(ClientFolder)\ClientProject.sln</ClientSolution>
</PropertyGroup>
<Target Name="BuildClient">
<!--Restore Nuget-->
<Message Text="Starting Restoring Nuget Packages" />
<Exec Command=" $(NugetExe) restore $(ClientSolution)" />
<Message Text="Finished Restoring Nuget Packages" />
<Import Project="$(ClientSolution)" />
<!--build project-->
</Target>
</Project>
But line with <Import> is underlined in VS, saying import should be on level up, not within <Target>. When I move <Import> a level up as suggested I get an execution error:
errorMSB4025: The project file could not be loaded. Data at the root level is invalid.
Any idea how to build whole project without major rewriting?
Silly me! the solution turns out to be very simple:
<MSBuild Projects="..\..\MySolution.sln" "/>
This did the trick with executing the build on .sln file
I got the pointer from this answer.
<MSBuild Projects="$(ProjectFile)" Targets="_WPPCopyWebApplication;"
Properties="OutDir=..\publish;Configuration=Release;Platform=AnyCPU" />
I am using above script to publish Asp.Net project. In the project settings, I have absolutely made sure debug symbols are generated in release mode. Still MsBuild is not generating the pdb files in the output.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>Full</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DocumentationFile>WebProject.xml</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
After looking at the Microsoft.Web.Publishing.targets source, I have found a variable (ExcludeGeneratedDebugSymbol) being set to True in Release mode. From the comments, it looks like they wanted to exclude symbols from WebSite project, but the condition is not properly set for WebApplication project.
So, I have decided to override my build scrip from the caller arguments and it worked like a charm. I have not yet ascertained any side affects it may cause or using the undocumented property for future stability, but it works for now.
From the Microsoft.Web.Publishing.target file
<!--For website we will always exclude debug symbols from publishing unless it is set explicitly by user in website publish profile-->
<ExcludeGeneratedDebugSymbol Condition="'$(ExcludeGeneratedDebugSymbol)'=='' And '$(_WebProjectType)' == 'WebSite'">True</ExcludeGeneratedDebugSymbol>
<ExcludeGeneratedDebugSymbol Condition="'$(ExcludeGeneratedDebugSymbol)'=='' And '$(Configuration)' == 'Release'">True</ExcludeGeneratedDebugSymbol>
<ExcludeGeneratedDebugSymbol Condition="'$(ExcludeGeneratedDebugSymbol)'==''">False</ExcludeGeneratedDebugSymbol>
I have updated my script as follows.
<MSBuild Projects="$(ProjectFile)" Targets="_WPPCopyWebApplication;"
Properties="OutDir=..\publish;Configuration=Release;Platform=AnyCPU"; ExcludeGeneratedDebugSymbol=false />
You could also updated your publish profile (.pubxml) file to include that property value. I had to do this today with the new build bits in TFS Build 2015 to have the web publishing include the .pdb files. See example contents of file with property added to bottom.
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<publishUrl>C:\Publish</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol>
</PropertyGroup>
</Project>
You can put this directly in your *.csproj file, as the last property group section (right before the Import elements):
<PropertyGroup>
<ExcludeGeneratedDebugSymbol Condition="$(DebugSymbols) == true">false</ExcludeGeneratedDebugSymbol>
</PropertyGroup>
I'm trying to automate the creation of Firefox addon for two different platforms by using MSbuild:
I have shared files set which are the same for Mac and Windows and have platform specific files.
I want to batch the task of making XPI(which is just a renamed Zip file) by platform, but I can't find the right way to add the platform agnostic(shared) files as input for Zip task. Currently, my solution is to duplicate shared files items with platform windows and with platform mac, and then batch Zip task by Platform parameter. I have a feeling that my solution is not optimal. Maybe community can propose a better solution. Below is the simplified solution I created with comments:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectMSBuildToolsPath Condition=" '$(ProjectMSBuildToolsPath)' == '' ">MSBuild</ProjectMSBuildToolsPath>
</PropertyGroup>
<!-- Required Import to use MSBuild Community Tasks -->
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<!-- Default platform type is shared-->
<ItemDefinitionGroup>
<ZipFiles>
<Platform>Shared</Platform>
</ZipFiles>
</ItemDefinitionGroup>
<ItemGroup>
<ZipFiles Include="chrome\overlay.js" />
<ZipFiles Include="chrome\Win\methodContainer.js">
<Platform>Win</Platform>
</ZipFiles>
<ZipFiles Include="chrome\Mac\dataContainer.js">
<Platform>Mac</Platform>
</ZipFiles>
</ItemGroup>
<Target Name="_PrepareItemsForZip" Outputs="$(Platform)">
<ItemGroup>
<!-- Merge Shared and Windows specific files -->
<ZipFilesToWin Include="#(ZipFiles)" Condition="('%(ZipFiles.Platform)' == 'Shared') Or ('%(ZipFiles.Platform)' == 'Win')" >
<Platform>Win</Platform>
</ZipFilesToWin>
<!-- Merge Shared and Mac specific files -->
<ZipFilesToMac Include="#(ZipFiles)" Condition="('%(ZipFiles.Platform)' == 'Shared') Or ('%(ZipFiles.Platform)' == 'Mac')" >
<Platform>Mac</Platform>
</ZipFilesToMac>
</ItemGroup>
<!-- Merge Mac and Windows files set -->
<ItemGroup>
<_ZipFiles Include="#(ZipFilesToWin);#(ZipFilesToMac)" />
</ItemGroup>
</Target>
<!-- batch zipping files based on input platform -->
<Target Name="MakeXPI" DependsOnTargets="_PrepareItemsForZip" Inputs="#(_ZipFiles)" Outputs="%(Platform)" >
<Message Text="Zipped files: #(_ZipFiles) %(Platform)" Importance="high"/>
<Zip Files="#(_ZipFiles)" WorkingDirectory="" ZipFileName="CoolAddon-%(Platform).xpi" ZipLevel="9" />
</Target>
</Project>
Extract them to file like SharedProperties.properties:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ZipFiles>
<Platform>Shared</Platform>
</ZipFiles>
<PropertyGroup>
</Project>
And then simply import in targets/script you need them:
<Project ... >
<Import Project="SharedProperties.properties" />