@@ -1539,8 +1539,14 @@ function Invoke-DotNetPack {
15391539 # Ensure output directory exists
15401540 New-Item - Path $OutputPath - ItemType Directory - Force | Write-InformationStream - Tags " Invoke-DotNetPack"
15411541
1542- # Check if any projects exist
1543- $projectFiles = @ (Get-ChildItem - Recurse - Filter * .csproj - ErrorAction SilentlyContinue)
1542+ # Check if any projects exist (excluding test projects)
1543+ $projectFiles = @ (Get-ChildItem - Recurse - Filter * .csproj - ErrorAction SilentlyContinue | Where-Object {
1544+ -not ($_.Name -match " \.Tests?\.csproj$" -or
1545+ $_.Directory.Name -match " \.Tests?$" -or
1546+ $_.Directory.Name -eq " Tests" -or
1547+ $_.Directory.Name -eq " Test" -or
1548+ (Select-String - Path $_.FullName - Pattern " <IsTestProject>true</IsTestProject>" - Quiet))
1549+ })
15441550 if ($projectFiles.Count -eq 0 ) {
15451551 Write-Information " No .NET library projects found to package" - Tags " Invoke-DotNetPack"
15461552 return
@@ -1563,21 +1569,23 @@ function Invoke-DotNetPack {
15631569 Write-Information " No latest changelog found, SDK will use full CHANGELOG.md (automatically truncated if needed)" - Tags " Invoke-DotNetPack"
15641570 }
15651571
1566- # Build either a specific project or all projects
1572+ # Build either a specific project or all non-test projects
15671573 if ([string ]::IsNullOrWhiteSpace($Project )) {
1568- Write-Information " Packaging all projects in solution..." - Tags " Invoke-DotNetPack"
1569- " dotnet pack --configuration $Configuration -logger:`" Microsoft.Build.Logging.ConsoleLogger,Microsoft.Build;Summary;ForceNoAlign;ShowTimestamp;ShowCommandLine;Verbosity=quiet`" --no-build --output $OutputPath $releaseNotesProperty " | Invoke-ExpressionWithLogging | Write-InformationStream - Tags " Invoke-DotNetPack"
1574+ Write-Information " Packaging $ ( $projectFiles.Count ) non-test projects..." - Tags " Invoke-DotNetPack"
1575+ foreach ($proj in $projectFiles ) {
1576+ $projName = [System.IO.Path ]::GetFileNameWithoutExtension($proj )
1577+ Write-Information " Packaging project: $projName " - Tags " Invoke-DotNetPack"
1578+ " dotnet pack `" $proj `" --configuration $Configuration -logger:`" Microsoft.Build.Logging.ConsoleLogger,Microsoft.Build;Summary;ForceNoAlign;ShowTimestamp;ShowCommandLine;Verbosity=quiet`" --no-build --output $OutputPath $releaseNotesProperty " | Invoke-ExpressionWithLogging | Write-InformationStream - Tags " Invoke-DotNetPack"
1579+ if ($LASTEXITCODE -ne 0 ) {
1580+ throw " Library packaging failed for $projName with exit code $LASTEXITCODE "
1581+ }
1582+ }
15701583 } else {
15711584 Write-Information " Packaging project: $Project " - Tags " Invoke-DotNetPack"
15721585 " dotnet pack $Project --configuration $Configuration -logger:`" Microsoft.Build.Logging.ConsoleLogger,Microsoft.Build;Summary;ForceNoAlign;ShowTimestamp;ShowCommandLine;Verbosity=quiet`" --no-build --output $OutputPath $releaseNotesProperty " | Invoke-ExpressionWithLogging | Write-InformationStream - Tags " Invoke-DotNetPack"
1573- }
1574-
1575- if ($LASTEXITCODE -ne 0 ) {
1576- # Get more details about what might have failed
1577- Write-Information " Packaging failed with exit code $LASTEXITCODE , trying again with quiet verbosity..." - Tags " Invoke-DotNetPack"
1578- " dotnet pack --configuration $Configuration -logger:`" Microsoft.Build.Logging.ConsoleLogger,Microsoft.Build;Summary;ForceNoAlign;ShowTimestamp;ShowCommandLine;Verbosity=quiet`" --no-build --output $OutputPath $releaseNotesProperty " | Invoke-ExpressionWithLogging | Write-InformationStream - Tags " Invoke-DotNetPack"
1579-
1580- throw " Library packaging failed with exit code $LASTEXITCODE "
1586+ if ($LASTEXITCODE -ne 0 ) {
1587+ throw " Library packaging failed with exit code $LASTEXITCODE "
1588+ }
15811589 }
15821590
15831591 # Report on created packages
@@ -1623,8 +1631,14 @@ function Invoke-DotNetPublish {
16231631
16241632 Write-StepHeader " Publishing Applications" - Tags " Invoke-DotNetPublish"
16251633
1626- # Find all projects
1627- $projectFiles = @ (Get-ChildItem - Recurse - Filter * .csproj - ErrorAction SilentlyContinue)
1634+ # Find all projects (excluding test projects)
1635+ $projectFiles = @ (Get-ChildItem - Recurse - Filter * .csproj - ErrorAction SilentlyContinue | Where-Object {
1636+ -not ($_.Name -match " \.Tests?\.csproj$" -or
1637+ $_.Directory.Name -match " \.Tests?$" -or
1638+ $_.Directory.Name -eq " Tests" -or
1639+ $_.Directory.Name -eq " Test" -or
1640+ (Select-String - Path $_.FullName - Pattern " <IsTestProject>true</IsTestProject>" - Quiet))
1641+ })
16281642 if ($projectFiles.Count -eq 0 ) {
16291643 Write-Information " No .NET application projects found to publish" - Tags " Invoke-DotNetPublish"
16301644 return
0 commit comments