Skip to content

Instantly share code, notes, and snippets.

@uniquelau
Last active December 14, 2015 01:29
Show Gist options
  • Save uniquelau/5006823 to your computer and use it in GitHub Desktop.
Save uniquelau/5006823 to your computer and use it in GitHub Desktop.
Example of a projects targets file
<?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>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>https://localhost:8172/MSDeploy.axd</MSDeployServiceURL>
<DeployIisAppPath>vdb.jobcode.project-DEV</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<UserName>Administrator</UserName>
<_SavePWD>False</_SavePWD>
<PublishDatabaseSettings>
<Objects xmlns="" />
</PublishDatabaseSettings>
</PropertyGroup>
<!-- DEPENDANCY on {project-name}.wpp.targets -->
<!-- [1] Custom ACL's -->
<ItemGroup>
<!-- ideally, this would just set the entire 'www' to writable - suggestions welcomed!! -->
<!--
<CustomDirAcl Include="$(_MSDeployDirPath_FullPath)"><AclAccess>Modify</AclAccess></CustomDirAcl>
-->
<CustomDirAcl Include="Config"><AclAccess>Modify</AclAccess></CustomDirAcl>
<CustomDirAcl Include="Css"><AclAccess>Modify</AclAccess></CustomDirAcl>
<CustomDirAcl Include="Masterpages"><AclAccess>Modify</AclAccess></CustomDirAcl>
<CustomDirAcl Include="Scripts"><AclAccess>Modify</AclAccess></CustomDirAcl>
<CustomDirAcl Include="Umbraco"><AclAccess>Modify</AclAccess></CustomDirAcl>
<CustomDirAcl Include="Xslt"><AclAccess>Modify</AclAccess></CustomDirAcl>
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This file contains the GLOBAL msbuild logic -->
<!-- Visual Studio caches this file, you must restart VS when you make changes :( -->
<!-- If you run from the command line, you will not have this problem :) -->
<!-- TABLE OF CONTENTS
[1] Set Custom ACL's
[1][a] Umbraco Folders
-->
<!-- [1] Set Custom ACL's -->
<PropertyGroup>
<AfterAddIisSettingAndFileContentsToSourceManifest>
DoSetAcl;
</AfterAddIisSettingAndFileContentsToSourceManifest>
<AfterAddIisAndContentDeclareParametersItems>
DoSetParam;
</AfterAddIisAndContentDeclareParametersItems>
<AfterAddDeclareParametersItems/>
</PropertyGroup>
<!-- [1][a] Umbraco Folders -->
<!-- WebDeploy will handle the standard .NET folders - e.g. App_Code, App_Browsers, App_Data, etc -->
<!-- For our production enviroment we want to allow editors to upload new images, so let's allow the /media folder -->
<ItemGroup>
<CustomDirAcl Include="Media"><AclAccess>Modify</AclAccess></CustomDirAcl>
</ItemGroup>
<!-- NOTE:: Please see Debug.pubxml for DEBUG folder permissions, e.g. anything is possible! ;) -->
<!-- The hard work! -->
<!-- Based on http://forums.iis.net/p/1176955/1977169.aspx#1977169 and Sayed's Blog -->
<Target Name="DoSetAcl">
<ItemGroup>
<MsDeploySourceManifest Include="setAcl">
<Path>$(_MSDeployDirPath_FullPath)</Path>
<setAclAccess>Read,Write</setAclAccess>
<setAclResourceType>Directory</setAclResourceType>
<AdditionalProviderSettings>setAclAccess</AdditionalProviderSettings>
</MsDeploySourceManifest>
<MsDeploySourceManifest Include="setAcl">
<Path>$(_MSDeployDirPath_FullPath)\%(CustomDirAcl.Identity)</Path>
<setAclAccess Condition="%(CustomDirAcl.AclAccess) != ''">%(CustomDirAcl.AclAccess)</setAclAccess>
<setAclAccess Condition="%(CustomDirAcl.AclAccess) == ''">FullControl</setAclAccess>
<AdditionalProviderSettings>setAclAccess</AdditionalProviderSettings>
</MsDeploySourceManifest>
</ItemGroup>
</Target>
<!-- Regex escaped to support directories with 's-->
<Target Name="DoSetParam" Outputs="%(CustomDirAcl.Identity)">
<EscapeTextForRegularExpressions Text="%(CustomDirAcl.Identity)">
<Output TaskParameter="Result" PropertyName="_EscapeRegEx_CustomDirAcl" />
</EscapeTextForRegularExpressions>
<ItemGroup>
<MsDeployDeclareParameters Include="SetAcl %(CustomDirAcl.Identity)">
<Kind>ProviderPath</Kind>
<Scope>setAcl</Scope>
<Match>^$(_EscapeRegEx_MSDeployDirPath)\\$(_EscapeRegEx_CustomDirAcl)$</Match>
<DefaultValue>{$(_MsDeployParameterNameForContentPath)}/@(CustomDirAcl)</DefaultValue>
<Value>$(_DestinationContentPath)/@(CustomDirAcl)</Value>
<Tags>Hidden</Tags>
<Priority>$(VsSetAclPriority)</Priority>
<ExcludeFromSetParameter>True</ExcludeFromSetParameter>
</MsDeployDeclareParameters>
</ItemGroup>
</Target>
<!-- [2] -->
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment