Skip to content

Commit

Permalink
minor update to ps1 (#1673)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlaviuTritean authored Oct 16, 2024
1 parent 519203f commit 901797a
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions build/PowerShellScripts/BuildSlnForCTE.ps1
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 ; }
}

0 comments on commit 901797a

Please sign in to comment.