-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathConvertWriteLineToLogMessageInProjects.ps1
More file actions
67 lines (53 loc) · 2.63 KB
/
ConvertWriteLineToLogMessageInProjects.ps1
File metadata and controls
67 lines (53 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
############ EDIT THIS SECTION ##############
$url = "****** TODO ********"
$tenant = "****** TODO ********"
$folder = "****** TODO ********"
$username = "****** TODO ********"
$password = "****** TODO ********"
$repositoryFolder = "****** TODO ********"
$newPackageFolder = "****** TODO ********"
#############################################
$regex = '<WriteLine.*DisplayName="(?<DisplayName>.*?)".*Text="(?<Text>.*?)".*\/>'
$affectedProjectFolders = New-Object System.Collections.ArrayList
$affectedFiles = New-Object System.Collections.ArrayList
$xamlFiles = (Get-ChildItem -Path $repositoryFolder -Force -Recurse -Filter "*.xaml")
foreach($file in $xamlFiles)
{
$originalFileContent = Get-Content $file.FullName -Encoding UTF8 -Raw
if ($originalFileContent -Match "<WriteLine")
{
$newFileContent = $originalFileContent -replace $regex, '<ui:LogMessage DisplayName="Log Message - ${DisplayName}" sap:VirtualizedContainerService.HintSize="334,91" sap2010:WorkflowViewState.IdRef="LogMessage_2" Level="Trace" Message="["${Text}"]" />'
[IO.File]::WriteAllText($file.FullName, $newFileContent)
Write-Host "Replaced WriteLine in file: $($file.FullName)"
$affectedFiles.Add($file) 1>$null
$currentFolder = $file.Directory
do
{
if (Test-Path ($currentFolder.FullName + "\project.json"))
{
$affectedProjectFolders.Add($currentFolder) 1>$null
break;
}
$currentFolder = $currentFolder.Parent
}while($repositoryFolder -ne $currentFolder.FullName)
}
}
$affectedProjectFolders = $affectedProjectFolders | Get-Unique
###############################################################
foreach($projectFolder in $affectedProjectFolders.FullName)
{
$projectJson = Get-Content "$projectFolder\project.json" | ConvertFrom-Json
Write-Host "Updating version of project: $($projectJson.name).$($projectJson.projectVersion)"
$uiRobotExe = '"C:\Program Files (x86)\UiPath\Studio\UiRobot.exe"'
$command = "$uiRobotExe pack $projectFolder\project.json --output $newPackageFolder"
iex "& $command" 1>$null
}
###############################################################
Import-Module UiPath.PowerShell
Get-UiPathAuthToken -URL $url -TenantName $tenant -Username $username -Password $password -Session -OrganizationUnit $folder 1>$null
$nugetsToUpload = (Get-ChildItem -Path $newPackageFolder -Force -Recurse -Filter "*.nupkg").FullName
foreach($packageFilePath in $nugetsToUpload)
{
Write-Host "Uploading package to Orchestrator: $packageFilePath"
Add-UiPathPackage -PackageFile $packageFilepath
}