Skip to content

Commit

Permalink
add property TargetModule to filter build/publish module (#11601)
Browse files Browse the repository at this point in the history
  • Loading branch information
erich-wang authored Apr 16, 2020
1 parent b46b487 commit 9105b2c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
14 changes: 11 additions & 3 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;Get-ChildItem -Path $(MSBuildThisFileDirectory) -Recurse -Include 'bin','obj','TestResults' | Remove-Item -Recurse -Force -ErrorAction Ignore&quot;" IgnoreExitCode="true" />
</Target>

<Target Name="FilterBuild" Condition="$(PullRequestNumber) != ''">
<Target Name="FilterBuild" Condition="$(PullRequestNumber) != '' OR $(TargetModule) != ''">
<Message Importance="high" Text="Filtering projects and modules..." />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CreateFilterMappings.ps1&quot;" />

<!-- Build the Microsoft.Azure.Build.Tasks project -->
<Exec Command="dotnet publish $(RepoTools)BuildPackagesTask/Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.csproj -c $(Configuration) -f netstandard2.0" />

<!-- Get all of the files changed in the given pull request -->
<FilesChangedTask RepositoryOwner="Azure" RepositoryName="azure-powershell" PullRequestNumber="$(PullRequestNumber)">
<FilesChangedTask RepositoryOwner="Azure" RepositoryName="azure-powershell" PullRequestNumber="$(PullRequestNumber)" TargetModule="$(TargetModule)">
<Output TaskParameter="FilesChanged" ItemName="FilesChanged" />
</FilesChangedTask>

Expand Down Expand Up @@ -143,7 +143,7 @@
<!-- Build and create package content -->
<Exec Command="dotnet --version" />
<Exec Command="dotnet new sln -n Azure.PowerShell -o $(RepoArtifacts) --force" />
<ItemGroup Condition="$(PullRequestNumber) == ''">
<ItemGroup Condition="$(PullRequestNumber) == '' AND $(TargetModule) == ''">
<CsprojFiles Include="$(RepoRoot)src/**/*.csproj" Exclude="$(RepoRoot)src/**/*.Test.csproj;$(RepoRoot)src/**/Authenticators.csproj" />
<CsprojFiles Include="$(RepoRoot)src/**/*.Test.csproj" Exclude="$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'All'" />
<CsprojFiles Include="$(RepoRoot)src/**/*.Test.csproj" Exclude="$(CoreTests)$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'NonCore'" />
Expand All @@ -156,6 +156,14 @@
<CsprojFiles Include="%(ProjectsToBuild.Identity)" />
<CsprojFiles Include="$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$([MSBuild]::IsOsPlatform(&quot;Windows&quot;))' == 'true'" />
</ItemGroup>
<ItemGroup Condition="$(TargetModule) != ''">
<!-- Add test projects only if Configuration is not Release -->
<CsprojFiles Include="$(LibraryRoot)src/Accounts/**/*.csproj;$(LibraryRoot)tools/TestFx/TestFx.csproj" Exclude="$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$(Configuration)' != 'Release'" />
<CsprojFiles Include="$(LibraryRoot)src/Accounts/**/*.csproj" Exclude="$(RepoRoot)src/**/*.Test.csproj;$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$(Configuration)' == 'Release'"/>
<CsprojFiles Include="%(ProjectsToBuild.Identity)" Condition="'$(Configuration)' != 'Release'" />
<CsprojFiles Include="%(ProjectsToBuild.Identity)" Exclude="$(RepoRoot)src/**/*.Test.csproj" Condition="'$(Configuration)' == 'Release'" />
<CsprojFiles Include="$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$([MSBuild]::IsOsPlatform(&quot;Windows&quot;))' == 'true'" />
</ItemGroup>
<!-- https://github.com/dotnet/cli/issues/6295#issuecomment-346973582 -->
<Exec Command="dotnet sln $(RepoArtifacts)Azure.PowerShell.sln add &quot;%(CsprojFiles.FullPath)&quot;" />
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public class FilesChangedTask : Task
/// </summary>
public string PullRequestNumber { get; set; }

/// <summary>
/// Gets or set the TargetModule, e.g. Az.Storage
/// </summary>
public string TargetModule { get; set; }

/// <summary>
/// Gets or sets the files changed produced by the task.
/// </summary>
Expand Down Expand Up @@ -132,6 +137,11 @@ public override bool Execute()

FilesChanged = filesChanged.ToArray();
}
else if(!string.IsNullOrEmpty(TargetModule))
{
//Add one FAKE changed file for TargetModule, so TargetModule will be included for FilterTask
FilesChanged = new string[] { $"src/{TargetModule}/changeLog.md" };
}
else
{
FilesChanged = new string[] { };
Expand Down

0 comments on commit 9105b2c

Please sign in to comment.