@@ -92,7 +92,8 @@ function Add-Codefirst-Projects-To-Cdsproj{
92
92
[Parameter (Mandatory )] [String ]$buildSourceDirectory ,
93
93
[Parameter (Mandatory )] [String ]$repo ,
94
94
[Parameter (Mandatory )] [String ]$solutionName ,
95
- [Parameter (Mandatory )] [String ]$pacPath
95
+ [Parameter (Mandatory )] [String ]$pacPath ,
96
+ [Parameter ()] [String ]$base64Snk
96
97
)
97
98
if (-not ([string ]::IsNullOrEmpty($pacPath )) -and (Test-Path " $pacPath \pac.exe" ))
98
99
{
@@ -118,8 +119,7 @@ function Add-Codefirst-Projects-To-Cdsproj{
118
119
foreach ($pcfProj in $pcfProjectFiles )
119
120
{
120
121
Write-Host " Adding Reference of Pcf Project - " $pcfProj.FullName
121
- $pcfProjectPath = " `" $ ( $pcfProj.FullName ) `" "
122
-
122
+ $pcfProjectPath = ' "' + $ ($pcfProj.FullName ) + ' "'
123
123
$addReferenceCommand = " solution add-reference --path $pcfProjectPath "
124
124
Write-Host " Add Reference Command - $addReferenceCommand "
125
125
Invoke-Expression - Command " $pacexepath $addReferenceCommand "
@@ -131,30 +131,47 @@ function Add-Codefirst-Projects-To-Cdsproj{
131
131
if (Test-Path " $unpackedPluginAssemblyPath " ){
132
132
# Get all .csproj files under Repo/Commited Solution folder
133
133
$csProjectFiles = Get-ChildItem - Path " $buildSourceDirectory \$repo \$solutionName " - Filter * .csproj - Recurse
134
- foreach ($csProject in $csProjectFiles )
134
+ Write-Host " $ ( $csProjectFiles.Count ) cs project files found"
135
+ # Filter out projects name ending with "Tests.csproj" (i.e.,Unit test projects)
136
+ $filteredProjects = $csProjectFiles | Where-Object { $_.Name -notlike " *Tests.csproj" }
137
+ Write-Host " $ ( $filteredProjects.Count ) plugin project files found after filtering out unit test projects"
138
+ foreach ($csProject in $filteredProjects )
135
139
{
136
140
Write-Host " Adding Reference of Plugin Project - " $csProject.FullName
137
- # Add only Plugin type csproj; Skip others
138
- $csProjectPath = " `" $ ( $csProject.FullName ) `" "
139
-
140
- # Read csproj xml to determin project type
141
- [xml ]$xmlDoc = Get-Content - Path $csProjectPath
142
- $tagPowerAppsTargetsPath = $xmlDoc.Project.PropertyGroup.PowerAppsTargetsPath
143
-
144
- # 'PowerAppsTargetsPath' tag is only availble in plugin project generate via 'pac plugin init'
145
- if (-not [string ]::IsNullOrWhiteSpace($tagPowerAppsTargetsPath )){
146
- $addReferenceCommand = " solution add-reference --path $csProjectPath "
147
- Write-Host " Add Reference Command - $addReferenceCommand "
148
- Invoke-Expression - Command " $pacexepath $addReferenceCommand "
149
- }
150
- else {
151
- Write-Host " Not a plug-in project; Skipping add reference to cdsproj; Path - $csProjectPath "
141
+ $csProjectPath = ' "' + $ ($csProject.FullName ) + ' "'
142
+
143
+ # Read csproj file's AssemblyOriginatorKeyFile and SignAssembly properties.
144
+ # We need to read these properties to determine whether the C# project is signed.
145
+ [xml ]$xmlDoc = Get-Content - Path $ ($csProject.FullName )
146
+ $snkFileName = $xmlDoc.Project.PropertyGroup.AssemblyOriginatorKeyFile
147
+ $signAssembly = $xmlDoc.Project.PropertyGroup.SignAssembly
148
+ Write-Host " SNKFileName - $snkFileName "
149
+ Write-Host " SignAssembly - $signAssembly "
150
+ # Check for existing snk file or pull from global variables
151
+ if ($signAssembly -eq " true" ) {
152
+ $projectDirectory = [System.IO.Path ]::GetDirectoryName(" $csProject .FullName" )
153
+ Write-Host " SNK Path: $projectDirectory \$snkFileName "
154
+ if (! (Test-Path " $projectDirectory \$snkFileName " )) {
155
+ if (! ($base64Snk.Contains (' $(' ))) {
156
+ Write-Host " Writing plugin snk file to disk"
157
+ $bytes = [Convert ]::FromBase64String($base64Snk )
158
+ [IO.File ]::WriteAllBytes(" $projectDirectory \$snkFileName " , $bytes )
159
+ }else {
160
+ Write-Host " No snk found at repo and no snk content defined in variables"
161
+ }
162
+ }else {
163
+ Write-Host " .snk file - $snkFileName already presents in the repo. No need to read from variable"
164
+ }
152
165
}
166
+
167
+ $addReferenceCommand = " solution add-reference --path $csProjectPath "
168
+ Write-Host " Add Reference Command - $addReferenceCommand "
169
+ Invoke-Expression - Command " $pacexepath $addReferenceCommand "
153
170
}
154
171
}
155
172
else
156
173
{
157
- Write-Host " PluginAssemblies folder unavailble in unpacked solution"
174
+ Write-Host " PluginAssemblies folder unavailable in unpacked solution"
158
175
}
159
176
}
160
177
else
@@ -501,42 +518,4 @@ function Invoke-Append-Version-To-Solutions{
501
518
{
502
519
Write-Host " Unmanaged solution is unavailble at unmanagedSolutionPath"
503
520
}
504
- }
505
-
506
- <#
507
- This function checks the existence of unit test projects under the repository.
508
- This function is needed to run the plugin test projects.
509
- #>
510
- function Invoke-Check-Test-Projects {
511
- param (
512
- [Parameter (Mandatory )] [String ]$buildSourceDirectory ,
513
- [Parameter (Mandatory )] [String ]$repo ,
514
- [Parameter (Mandatory )] [String ]$solutionName
515
- )
516
-
517
- $testProjectsPath = " $buildSourceDirectory \$repo \$solutionName \Test"
518
- If (Test-Path " $testProjectsPath " )
519
- {
520
- csProjectFiles = Get-ChildItem - Path " $testProjectsPath " - Filter * .csproj - Recurse
521
- foreach ($csProject in $csProjectFiles )
522
- {
523
- # Add only Plugin type csproj; Skip others
524
- $csProjectPath = $csProject.FullName
525
-
526
- # Read csproj xml to determin project type
527
- [xml ]$xmlDoc = Get-Content - Path $csProjectPath
528
- $testProjectType = $xmlDoc.Project.PropertyGroup.TestProjectType
529
-
530
- # 'TestProjectType' tag is available only to Test projects
531
- if (-not [string ]::IsNullOrWhiteSpace($testProjectType )){
532
- Write-Host " Test projects exist in the Repo - $csProjectPath "
533
- Write-Host " ##vso[task.setvariable variable=pluginstestexists;]$true "
534
- break
535
- }
536
- }
537
- }
538
- else
539
- {
540
- Write-Host " Test projects not exist under $testProjectsPath "
541
- }
542
521
}
0 commit comments