Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/actions/build/ci/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: CI Build
description: 'Builds PowerShell'
inputs:
ExtraBuildParams:
description: 'Extra Build Params'
default: ''
SkipXUnitTests:
description: 'Skip xUnit Tests'
default: 'false'
runs:
using: composite
steps:
Expand Down Expand Up @@ -29,8 +36,9 @@ runs:
run: |-
Write-Verbose -Verbose "Running Build..."
Import-Module .\tools\ci.psm1
Invoke-CIBuild
Invoke-CIBuild -ExtraBuildParams '${{ inputs.ExtraBuildParams }}'
shell: pwsh

- name: xUnit Tests
if: success()
continue-on-error: true
Expand All @@ -42,6 +50,7 @@ runs:
shell: pwsh
- name: Upload build artifact
uses: actions/upload-artifact@v4
if: eq('${{ inputs.SkipXUnitTests }}', 'true')
with:
name: build
path: ${{ runner.workspace }}/build
Expand All @@ -50,3 +59,4 @@ runs:
with:
name: testResults-xunit
path: ${{ runner.workspace }}/xunit
if: eq('${{ inputs.SkipXUnitTests }}', 'true')
170 changes: 170 additions & 0 deletions .github/workflows/windows-ci-rebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: Windows-CI-BuildFromPackages
on:
workflow_dispatch:
push:
branches:
- release/**
- github-mirror
paths:
- "**"
- "!.vsts-ci/misc-analysis.yml"
- "!.github/ISSUE_TEMPLATE/**"
- "!.dependabot/config.yml"
- "!test/perf/**"
- "!.pipelines/**"
pull_request:
branches:
- release/**
- github-mirror

# Path filters for PRs need to go into the changes job

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ contains(github.ref, 'merge')}}

permissions:
contents: read

run-name: "${{ github.ref_name }} - ${{ github.run_number }}"

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
GIT_CONFIG_PARAMETERS: "'core.autocrlf=false'"
NugetSecurityAnalysisWarningLevel: none
POWERSHELL_TELEMETRY_OPTOUT: 1
__SuppressAnsiEscapeSequences: 1
nugetMultiFeedWarnLevel: none
jobs:
changes:
name: Change Detection
runs-on: ubuntu-latest
if: startsWith(github.repository_owner, 'azure') || github.repository_owner == 'PowerShell'
# Required permissions
permissions:
pull-requests: read
contents: read

# Set job outputs to values from filter step
outputs:
source: ${{ steps.filter.outputs.source }}
steps:
- name: checkout
uses: actions/checkout@v4.1.0

- name: Change Detection
id: filter
uses: "./.github/actions/infrastructure/path-filters"
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ci_build:
name: Build PowerShell
needs: changes
if: ${{ needs.changes.outputs.source == 'true' }}
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v4.1.0
with:
fetch-depth: 1000
- name: Build
uses: "./.github/actions/build/ci"
with:
ExtraBuildParams: BuildFromPackages
SkipXUnitTests: true
windows_test_unelevated_ci:
name: Windows Unelevated CI
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' }}
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v4.1.0
with:
fetch-depth: 1000
- name: Windows Unelevated CI
uses: "./.github/actions/test/windows"
with:
purpose: UnelevatedPesterTests
tagSet: CI
windows_test_elevated_ci:
name: Windows Elevated CI
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' }}
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v4.1.0
with:
fetch-depth: 1000
- name: Windows Elevated CI
uses: "./.github/actions/test/windows"
with:
purpose: ElevatedPesterTests
tagSet: CI
windows_test_unelevated_others:
name: Windows Unelevated Others
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' }}
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v4.1.0
with:
fetch-depth: 1000
- name: Windows Unelevated Others
uses: "./.github/actions/test/windows"
with:
purpose: UnelevatedPesterTests
tagSet: Others
windows_test_elevated_others:
name: Windows Elevated Others
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' }}
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v4.1.0
with:
fetch-depth: 1000
- name: Windows Elevated Others
uses: "./.github/actions/test/windows"
with:
purpose: ElevatedPesterTests
tagSet: Others
# verify_xunit:
# name: Verify xUnit test results
# needs:
# - ci_build
# - changes
# if: ${{ needs.changes.outputs.source == 'true' }}
# runs-on: windows-latest
# steps:
# - name: checkout
# uses: actions/checkout@v4.1.0
# with:
# fetch-depth: 1000
# - name: Verify xUnit test results
# uses: "./.github/actions/test/verify_xunit"
ready_to_merge:
name: windows ready to merge
needs:
# - verify_xunit
- windows_test_elevated_ci
- windows_test_elevated_others
- windows_test_unelevated_ci
- windows_test_unelevated_others
if: always()
uses: PowerShell/compliance/.github/workflows/ready-to-merge.yml@v1.0.0
with:
needs_context: ${{ toJson(needs) }}
14 changes: 10 additions & 4 deletions PowerShell.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,27 @@
For RCs, we will increment the iteration from 100.

Examples
7.2.0 becomes 7.2.0
7.2.0-preview.1 becomes 7.2.0.1
7.2.0-rc.1 becomes 7.2.0.101
7.2.0 becomes 7.2.0.500
7.2.1 becomes 7.2.0.500
7.2.0-preview.1 becomes 7.2.0.4
7.2.0-preview.2 becomes 7.2.0.4
7.2.0-rc.1 becomes 7.2.0.100
7.2.0-rc.2 becomes 7.2.0.100
-->

<!-- parse the release tag into the parts we need -->
<RegexReleaseTag>^((\d+).(\d+).(\d+))(-(\w+)(.(\d+))?)?$</RegexReleaseTag>
<ReleaseTagVersionPart>$([System.Text.RegularExpressions.Regex]::Match($(ReleaseTag), $(RegexReleaseTag)).Groups[1].Value)</ReleaseTagVersionPart>
<ReleaseTagSemVersionPart>$([System.Text.RegularExpressions.Regex]::Match($(ReleaseTag), $(RegexReleaseTag)).Groups[8].Value)</ReleaseTagSemVersionPart>
<ReleaseTagSemVersionPrereleaseNamePart>$([System.Text.RegularExpressions.Regex]::Match($(ReleaseTag), $(RegexReleaseTag)).Groups[6].Value)</ReleaseTagSemVersionPrereleaseNamePart>
<!-- Increment revision 4 for preview releases -->
<PreviewSemVerPartValue>4</PreviewSemVerPartValue>
<!-- Increment revision 100 for rc releases -->
<RCIncrementValue>100</RCIncrementValue>
<!-- Increment revision 500 for GA releases -->
<GAIncrementValue>500</GAIncrementValue>
<ReleaseTagSemVersionPart Condition = "'$(ReleaseTagSemVersionPrereleaseNamePart)' == 'rc'">$([MSBuild]::Add($(ReleaseTagSemVersionPart), $(RCIncrementValue)))</ReleaseTagSemVersionPart>
<ReleaseTagSemVersionPart Condition = "'$(ReleaseTagSemVersionPrereleaseNamePart)' != 'rc'">$(PreviewSemVerPartValue)</ReleaseTagSemVersionPart>
<ReleaseTagSemVersionPart Condition = "'$(ReleaseTagSemVersionPrereleaseNamePart)' == 'rc'">$(RCIncrementValue)</ReleaseTagSemVersionPart>
<!-- Create the internal version -->
<PSCoreBuildVersion>$(ReleaseTag)</PSCoreBuildVersion>
<!-- Create the version if we have a pre-release -->
Expand Down
5 changes: 5 additions & 0 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function Start-PSBuild {
[switch]$NoPSModuleRestore,
[switch]$CI,
[switch]$ForMinimalSize,
[switch]$BuildFromPackages,

# Skips the step where the pwsh that's been built is used to create a configuration
# Useful when changing parsing/compilation, since bugs there can mean we can't get past this step
Expand Down Expand Up @@ -471,6 +472,10 @@ Fix steps:
$Arguments += "--self-contained"
}

if($BuildFromPackages) {
$Arguments += "/property:Rebuild=true"
}

if ($Options.Runtime -like 'win*') {
# Starting in .NET 8, the .NET SDK won't recognize version-specific RIDs by default, such as win7-x64,
# see https://learn.microsoft.com/dotnet/core/compatibility/sdk/8.0/rid-graph for details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
<Resource Include="resources\Graphics\SpyGlass16.png" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(Rebuild)' == 'true'">
<PackageReference Include="System.Management.Automation" Version="7.5.2" />
<PackageReference Include="Microsoft.PowerShell.Commands.Utility" Version="7.5.2" />
</ItemGroup>
<ItemGroup Condition="'$(Rebuild)' != 'true'">
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
<ProjectReference Include="..\Microsoft.PowerShell.Commands.Utility\Microsoft.PowerShell.Commands.Utility.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<Import Project="..\..\PowerShell.Common.props" />
<Import Project="..\Module.Common.props" />
<PropertyGroup>
<Description>PowerShell's Microsoft.PowerShell.Commands.Management project</Description>
<NoWarn>$(NoWarn);CS1570;CA1416</NoWarn>
Expand Down Expand Up @@ -49,6 +50,8 @@
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.Diagnostics.EventLog" Version="9.0.6" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="9.0.6" />
<PackageReference Include="System.Management" Version="9.0.6" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<Import Project="..\..\PowerShell.Common.props" />
<Import Project="..\Module.Common.props" />
<PropertyGroup>
<Description>PowerShell's Microsoft.PowerShell.Commands.Utility project</Description>
<NoWarn>$(NoWarn);CS1570;CA1416</NoWarn>
Expand All @@ -11,15 +12,17 @@
<PackageReference Include="JsonPointer.Net" Version="5.0.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</PackageReference>
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="9.0.6" />
<PackageReference Include="System.Reflection.Metadata" Version="8.0.1" />
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
<PackageReference Include="Markdig.Signed" Version="0.38.0" />
<PackageReference Include="Microsoft.PowerShell.MarkdownRender" Version="7.2.1" />
<!-- the following package(s) are from https://github.com/JamesNK/Newtonsoft.Json -->
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.DirectoryServices" Version="9.0.6" />
</ItemGroup>


<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup Condition="'$(Rebuild)' != 'true'">
<ProjectReference Include="..\Microsoft.PowerShell.ConsoleHost\Microsoft.PowerShell.ConsoleHost.csproj" />
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.PowerShell.Commands.Management\Microsoft.PowerShell.Commands.Management.csproj" />
<ProjectReference Include="..\Microsoft.PowerShell.Commands.Utility\Microsoft.PowerShell.Commands.Utility.csproj" />
<ProjectReference Include="..\Microsoft.PowerShell.ConsoleHost\Microsoft.PowerShell.ConsoleHost.csproj" />
<ProjectReference Include="..\Microsoft.PowerShell.Security\Microsoft.PowerShell.Security.csproj" />
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
<AssemblyName>Microsoft.PowerShell.Security</AssemblyName>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>
<Import Project="..\Module.Common.props" />

<ItemGroup>
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="9.0.6" />
<Compile Remove="singleshell\installer\MshSecurityMshSnapin.cs" />
<Compile Remove="gen\SecurityMshSnapinResources.cs" />

Expand Down
20 changes: 20 additions & 0 deletions src/Module.Common.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="'$(Rebuild)' == 'true' and '$(IsWindows)' =='true'">
<PackageReference Include="System.Management.Automation" Version="7.5.2">
<ExcludeAssets>compile</ExcludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Reference Include="System.Management.Automation">

<HintPath>$(NuGetPackageRoot)System.Management.Automation\7.5.2\runtimes\win\lib\net9.0\System.Management.Automation.dll</HintPath>
<Private>true</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Rebuild)' == 'true' and '$(IsWindows)' !='true'">
<PackageReference Include="System.Management.Automation" Version="7.5.2">
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(Rebuild)' != 'true'">
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>
</Project>
12 changes: 11 additions & 1 deletion src/powershell-win-core/powershell-win-core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,21 @@
</Content>
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(Rebuild)' == 'true'">
<ProjectReference Include="..\Microsoft.PowerShell.SDK\Microsoft.PowerShell.SDK.csproj" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.5.2" />
Comment on lines +49 to +50
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeat project reference.

<PackageReference Include="Microsoft.PowerShell.ConsoleHost" Version="7.5.2" />
<PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="7.5.2" />
<PackageReference Include="Microsoft.Management.Infrastructure.CimCmdlets" Version="7.5.2" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.5.2" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we parameterize this 7.5.2 value? It is used in many places.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, parameterizing the version number 7.5.2 is a smart move—especially since it's repeated across multiple entries. This makes your project easier to maintain and update in the future. Instead of hunting down every instance of the version string, you can change it in one place.

</ItemGroup>
<ItemGroup Condition="'$(Rebuild)' != 'true'">
<ProjectReference Include="..\Microsoft.PowerShell.SDK\Microsoft.PowerShell.SDK.csproj" />
<ProjectReference Include="..\Microsoft.PowerShell.Commands.Diagnostics\Microsoft.PowerShell.Commands.Diagnostics.csproj" />
<ProjectReference Include="..\Microsoft.Management.Infrastructure.CimCmdlets\Microsoft.Management.Infrastructure.CimCmdlets.csproj" />
<ProjectReference Include="..\Microsoft.WSMan.Management\Microsoft.WSMan.Management.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Management.UI.Internal\Microsoft.PowerShell.GraphicalHost.csproj" Condition="'$(SDKToUse)' == 'Microsoft.NET.Sdk.WindowsDesktop' "/>
</ItemGroup>

Expand Down
Loading
Loading