diff --git a/build/PowerShellScripts/BuildSlnForCTE.ps1 b/build/PowerShellScripts/BuildSlnForCTE.ps1 index 100199037..2913954b4 100644 --- a/build/PowerShellScripts/BuildSlnForCTE.ps1 +++ b/build/PowerShellScripts/BuildSlnForCTE.ps1 @@ -1,17 +1,20 @@ -# Define the root directory of your repository -$repoPath = "D:\a\1\s\" +param( +[string]$directoryPath = "" +) -# Define the folder name you want to delete -$folderName = "NuGet" +if (-not $directoryPath) { + $directoryPath = $env:SYSTEM_DEFAULTWORKINGDIRECTORY +} -# Get the path to the AppData directory +$folderName = "NuGet" $appDataPath = [System.Environment]::GetFolderPath('ApplicationData') - -# Combine the AppData path with the folder name $folderPath = Join-Path -Path $appDataPath -ChildPath $folderName +# Define the root directory of your repository +$repoPath = "D:\a\1\s\" + # Get all .csproj files in the repository -$csprojFiles = Get-ChildItem -Path $repoPath -Recurse -Filter *.csproj | Select-Object -ExpandProperty FullName +$csprojFiles = Get-ChildItem -Path $repoPath -Recurse -Filter *.sln | Select-Object -ExpandProperty FullName # Function to find MSBuild location by checking common paths function Get-MSBuildLocation { @@ -45,15 +48,17 @@ $msbuildLocation = Get-MSBuildLocation Set-Alias MSBuild -Value $msbuildLocation; + $feedName = 'SDLNuget' -$nugetRestoreArguments = "/p:nugetInteractive=true /p:RestoreSources=https://pkgs.dev.azure.com/sdl/_packaging/$feedName/nuget/v3/index.json" -$msbuildArguments = '/p:Configuration=Release /p:Platform="Any CPU" /flp:logfile=$(System.DefaultWorkingDirectory)/AzureLogs/MyLog.log;append=true' +$nugetRestoreArguments = "/p:RestoreSources=https://pkgs.dev.azure.com/sdl/_packaging/$feedName/nuget/v3/index.json" +$msbuildArguments = "/flp:logfile=$directoryPath/AzureLogs/MyLog.log;append=true" foreach ($project in $csprojFiles) { - if (Test-Path -Path $folderPath) { + if (Test-Path -Path $folderPath) { Remove-Item -Path $folderPath -Recurse -Force } - MSBuild "/bl" -m "$project" "/t:Restore" /p:nugetInteractive=true $nugetRestoreArguments - MSBuild "/bl" -m "$project" "/t:Rebuild" $msbuildArguments + # MSBuild "/bl" -m "$project" "/t:Restore" /p:nugetInteractive=true $nugetRestoreArguments + MSBuild "/bl" -m "$project" "/t:Restore" $nugetRestoreArguments -p:RestorePackagesConfig=true + MSBuild -m "$project" "/t:Rebuild" $msbuildArguments if (! $?) { write-Host "msbuild failed" -ForegroundColor Red ; } } \ No newline at end of file