Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # download SharePoint designer workflow from Site Assets
- # and update solution and feature IDs to match previous version
- $version = "2.0"
- if($args -ne $null -and $args.Length -gt 0){
- $version = $args[0]
- }
- $origWspFile = "Workflow Process 2.0.wsp"
- $destWspFile = $origWspFile.Replace("2.0.wsp", "$($version)_new.wsp")
- $webFolder = "http://devintranet/sites/workflowssite/SiteAssets"
- $workDir = "C:\DeploymentScripts\workflowssite\$($version)"
- $destDir = "$($workDir)\WSP"
- $webFile = "$($webFolder)/$($origWspFile)"
- $wspFile = "$($workDir)\$($origWspFile)"
- $userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;)"
- Remove-Item -Recurse -Force $workDir -ErrorAction SilentlyContinue
- New-Item $workDir -type directory
- set-location $workDir
- $wc = New-Object System.Net.WebClient
- $wc.UseDefaultCredentials = $true
- $wc.Headers.Add("user-agent", $userAgent)
- $wc.DownloadFile($webFile, $wspFile)
- Remove-Item -Recurse -Force $destDir -ErrorAction SilentlyContinue
- New-Item $destDir -type directory
- expand -R -F:* "$($origWspFile)" WSP
- $fps = "$($destDir)\manifest.xml"
- $xml = [xml](Get-Content $fps)
- $xml.Solution.SolutionId = "{dd48ffd2-6ee3-4cba-94c0-721887f2ad1c}"
- $xml.Save($fps)
- $fpf1 = "$($destDir)\Workflow Process 2.0WebEventReceivers\Feature.xml"
- $xml = [xml](Get-Content $fpf1)
- $xml.Feature.Id = "{4be55305-1708-4a75-a537-2682e7c77550}"
- # $xml.Feature.Version = "$($version).0.0"
- $xml.Save($fpf1)
- $fpf2 = "$($destDir)\Workflow Process 2.0ListInstances\Feature.xml"
- $xml = [xml](Get-Content $fpf2)
- $xml.Feature.Id = "{ea607063-4ad3-4414-b837-605794944cb2}"
- $xml.Feature.Title = "Workflow Process Workflow"
- # $xml.Feature.Version = "$($version).0.0"
- $xml.Save($fpf2)
- $len = $destDir.Length + 1
- $files = Get-ChildItem $destDir -Recurse |?{ -not $_.PSIsContainer }|%{$_.FullName}|%{$_.SubString($len)}
- $ddfTemplate = @"
- ;*** Diamond Directive File
- ;
- ;
- .OPTION EXPLICIT ; Generate errors on variable typos
- ;
- .Set CabinetNameTemplate=ppp.cab ; The name of the WSP file
- .set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory
- .Set CompressionType=MSZIP ;
- .Set Cabinet=on ;
- .Set Compress=on ;
- .Set DiskDirectory1=. ; Use the specified directory for the output CAB file
- ;
- ;*** Disable size limits for wsp (cab) files ;
- ;
- .Set CabinetFileCountThreshold=0
- .Set FolderFileCountThreshold=0
- .Set FolderSizeThreshold=0
- .Set MaxCabinetSize=0
- .Set MaxDiskFileCount=0
- .Set MaxDiskSize=0
- ;
- ;*** Files to zip ;
- ;
- "@
- $lines = $ddfTemplate.Split([string[]]"`n",'None')
- $ddfFilePath = "$($destDir)\solution.dff"
- $stream = New-Object System.IO.StreamWriter($ddfFilePath);
- foreach($line in $lines){
- $stream.WriteLine($line)
- }
- foreach($file in $files){
- $stream.WriteLine("`"$($destDir)\$($file)`" `"$($file)`"")
- }
- $stream.Close()
- set-location $destDir
- makecab.exe /F solution.dff
- Rename-Item ppp.cab "$($destWspFile)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement