Created
September 13, 2013 22:49
-
-
Save chrisobriensp/6557076 to your computer and use it in GitHub Desktop.
Custom MSBuild steps for a SharePoint .csproj file - to perform find/replace of SspId value for Managed Metadata fields in Office 365.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Import Project="$(VSToolsPath)\SharePointTools\Microsoft.VisualStudio.SharePoint.targets" Condition="'$(VSToolsPath)' != ''" /> | |
<!-- COB 15/08/2013: This next target does the work of replacing the SspId.. --> | |
<Target Name="AfterLayout" Condition="$(Configuration) != 'Debug' AND $(Configuration) != 'Release'"> | |
<!-- Set some variables.. --> | |
<PropertyGroup> | |
<ReplacementsFile>_Replacements\SspId_Replacements.xml</ReplacementsFile> | |
</PropertyGroup> | |
<!-- Fetch the appropriate value from the environments.xml file.. --> | |
<Message Text="Going to look for Environment node with Name ='$(Configuration)' in file $(ReplacementsFile).." Importance="high" /> | |
<XmlPeek XmlInputPath="$(ReplacementsFile)" Query="Replacements/Environment[@Name='$(Configuration)']/SspId/text()"> | |
<Output TaskParameter="Result" ItemName="FetchedSspIdValue" /> | |
</XmlPeek> | |
<Message Text="Fetched SspId value of @(FetchedSspIdValue) from $(ReplacementsFile) file" Importance="high" /> | |
<!-- Now make replacements.. --> | |
<ItemGroup> | |
<FilesForSspIdReplacement Include="$(LayoutPath)**\*.xml"> | |
</FilesForSspIdReplacement> | |
</ItemGroup> | |
<!-- In elements.xml files containing field definitions.. --> | |
<XmlPoke XmlInputPath="%(FilesForSspIdReplacement.Identity)" Namespaces="<Namespace Prefix='x' Uri='http://schemas.microsoft.com/sharepoint/'/><Namespace Prefix='q1' Uri='http://www.w3.org/2001/XMLSchema'/><Namespace Prefix='p4' Uri='http://www.w3.org/2001/XMLSchema-instance'/>" Query="x:Elements/x:Field/x:Customization/x:ArrayOfProperty/x:Property[x:Name='SspId']/x:Value" Value="@(FetchedSspIdValue)" /> | |
<!-- ..and in list schema.xml files.. --> | |
<XmlPoke XmlInputPath="%(FilesForSspIdReplacement.Identity)" Namespaces="<Namespace Prefix='x' Uri='http://schemas.microsoft.com/sharepoint/'/><Namespace Prefix='q1' Uri='http://www.w3.org/2001/XMLSchema'/><Namespace Prefix='p4' Uri='http://www.w3.org/2001/XMLSchema-instance'/><Namespace Prefix='ows' Uri='Microsoft SharePoint'/>" Query="x:List/x:MetaData/x:Fields/x:Field/x:Customization/x:ArrayOfProperty/x:Property[x:Name='SspId']/x:Value" Value="@(FetchedSspIdValue)" /> | |
</Target> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment