Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add property TargetModule to filter build/publish module #11601

Merged
merged 1 commit into from
Apr 16, 2020
Merged
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
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 @@ -42,6 +42,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 @@ -125,6 +130,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