Skip to content

Commit

Permalink
Refactor props and target file naming (Azure#19661)
Browse files Browse the repository at this point in the history
- Use better names for the properties that control
  what set of imports get pulled in at the root.
- Define IsMgmtLibrary property for mgmt
- Define IsClientLIbrary property for new Azure.Core base library
- Remove incorrectly defined IsDataPlaneProject property
- Rename Directory.Build.Data.props/targets to Directory.Build.Common.props/targets
  • Loading branch information
weshaggard authored Mar 29, 2021
1 parent b45670a commit 0c7110c
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 66 deletions.
12 changes: 8 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
<RepoEngPath>$(MSBuildThisFileDirectory)eng</RepoEngPath>
<RepoSrcPath>$(RepoRoot)src</RepoSrcPath>
<RepoSdkPath>$(RepoRoot)src/SDKs</RepoSdkPath>
<IsClientLibrary Condition="'$(IsClientLibrary)' == '' and $(MSBuildProjectName.StartsWith('Azure.'))">true</IsClientLibrary>
<IsDataPlaneProject Condition="'$(IsDataPlaneProject)' == '' and '$(IsClientLibrary)' == 'true'">true</IsDataPlaneProject>
<IsLegacyMgmtProject Condition="'$(IsLegacyMgmtProject)' == '' and $(MSBuildProjectName.Contains('.Management.'))">true</IsLegacyMgmtProject>
<ProjectStartsWithStandardName Condition="$(MSBuildProjectName.StartsWith('Azure.')) or $(MSBuildProjectName.StartsWith('Microsoft.'))">true</ProjectStartsWithStandardName>
<ImportRepoCommonSettings Condition="'$(ImportRepoCommonSettings)' == '' and '$(ProjectStartsWithStandardName)' == 'true' and '$(IsLegacyMgmtProject)' != 'true'">true</ImportRepoCommonSettings>
</PropertyGroup>

<!-- Setup default project properties -->
Expand Down Expand Up @@ -33,8 +34,11 @@
<IntermediateOutputPath Condition="'$(PlatformName)' != 'AnyCPU'">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>

<PackageOutputPath>$(ArtifactsPackagesDir)/$(MSBuildProjectName)</PackageOutputPath>

<!-- Used to help catch projects that use this property but don't end up importing our props below -->
<RequiredTargetFrameworks>import-required-properties</RequiredTargetFrameworks>
</PropertyGroup>

<Import Project="$(RepoEngPath)\mgmt\Directory.Build.Mgmt.props" Condition="'$(IsDataPlaneProject)' != 'true'" />
<Import Project="$(RepoEngPath)\Directory.Build.Data.props" Condition="'$(IsDataPlaneProject)' == 'true'" />
<Import Project="$(RepoEngPath)\mgmt\Directory.Build.Mgmt.props" Condition="'$(IsLegacyMgmtProject)' == 'true'" />
<Import Project="$(RepoEngPath)\Directory.Build.Common.props" Condition="'$(ImportRepoCommonSettings)' == 'true'" />
</Project>
13 changes: 10 additions & 3 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(RepoEngPath)\mgmt\Directory.Build.Mgmt.targets" Condition="'$(IsDataPlaneProject)' != 'true'" />
<Import Project="$(RepoEngPath)\Directory.Build.Data.targets" Condition="'$(IsDataPlaneProject)' == 'true'" />
</Project>
<ItemGroup Condition="'$(IsTestProject)' == 'true' or '$(IsPerfProject)' == 'true' or '$(IsStressProject)' == 'true'">
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>SourcePath</_Parameter1>
<_Parameter2>$(MSBuildProjectDirectory)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>

<Import Project="$(RepoEngPath)\mgmt\Directory.Build.Mgmt.targets" Condition="'$(IsLegacyMgmtProject)' == 'true'" />
<Import Project="$(RepoEngPath)\Directory.Build.Common.targets" Condition="'$(ImportRepoCommonSettings)' == 'true'" />
</Project>
33 changes: 21 additions & 12 deletions eng/Directory.Build.Data.props → eng/Directory.Build.Common.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Setup project type properties -->
<PropertyGroup>
<IsMgmtLibrary Condition="'$(IsMgmtLibrary)' == '' and $(MSBuildProjectName.StartsWith('Azure.ResourceManager.'))">true</IsMgmtLibrary>
<MgmtAutorestVersion>3.0.0-beta.20210319.1</MgmtAutorestVersion>

<!-- Client in this context is any library that is following the new Azure SDK guidelines -->
<IsClientLibrary Condition="'$(IsClientLibrary)' == '' and $(MSBuildProjectName.StartsWith('Azure.'))">true</IsClientLibrary>

<IsTestProject Condition="'$(IsTestProject)' == '' and $(MSBuildProjectName.EndsWith('.Tests'))">true</IsTestProject>
<IsSamplesProject Condition="'$(IsSamplesProject)' == '' and $(MSBuildProjectName.EndsWith('.Samples'))">true</IsSamplesProject>
<IsPerfProject Condition="'$(IsPerfProject)' == '' and $(MSBuildProjectName.EndsWith('.Perf'))">true</IsPerfProject>
<IsStressProject Condition="'$(IsStressProject)' == '' and $(MSBuildProjectName.EndsWith('.Stress'))">true</IsStressProject>
<IsTestSupportProject Condition="'$(IsTestSupportProject)' == '' and '$(IsTestProject)' != 'true' and ($(MSBuildProjectDirectory.Contains('/tests/')) or $(MSBuildProjectDirectory.Contains('\tests\')))">true</IsTestSupportProject>
<IsShippingLibrary Condition="'$(IsShippingLibrary)' == '' and '$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true' and '$(IsPerfProject)' != 'true' and '$(IsSamplesProject)' != 'true' and '$(IsStressProject)' != 'true'">true</IsShippingLibrary>
<IsShippingClientLibrary Condition="'$(IsClientLibrary)' == 'true' and '$(IsShippingLibrary)' == 'true'">true</IsShippingClientLibrary>
</PropertyGroup>

<!-- Setup default project properties -->
<PropertyGroup>
<LangVersion>latest</LangVersion>
Expand Down Expand Up @@ -40,16 +58,6 @@
</PropertyGroup>

<PropertyGroup>
<IsMgmtClientLibrary Condition="'$(IsMgmtClientLibrary)' == '' and ($(MSBuildProjectName.StartsWith('Azure.Management.')) or $(MSBuildProjectName.StartsWith('Azure.ResourceManager.')))">true</IsMgmtClientLibrary>
<MgmtAutorestVersion>3.0.0-beta.20210319.1</MgmtAutorestVersion>
<IsTestProject Condition="$(MSBuildProjectName.EndsWith('.Tests'))">true</IsTestProject>
<IsSamplesProject Condition="$(MSBuildProjectName.EndsWith('.Samples'))">true</IsSamplesProject>
<IsPerfProject Condition="$(MSBuildProjectName.EndsWith('.Perf'))">true</IsPerfProject>
<IsStressProject Condition="$(MSBuildProjectName.EndsWith('.Stress'))">true</IsStressProject>
<IsTestSupportProject Condition="'$(IsTestProject)' != 'true' and ($(MSBuildProjectDirectory.Contains('/tests/')) or $(MSBuildProjectDirectory.Contains('\tests\')))">true</IsTestSupportProject>
<IsShippingClientLibrary Condition="'$(IsClientLibrary)' == 'true' and '$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true' and '$(IsPerfProject)' != 'true' and '$(IsSamplesProject)' != 'true' and '$(IsStressProject)' != 'true'">true</IsShippingClientLibrary>
<IsShippingDataPlaneLibrary Condition="'$(IsDataPlaneProject)' == 'true' and '$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true' and '$(IsSamplesProject)' != 'true' and '$(IsPerfProject)' != 'true' and '$(IsStressProject)' != 'true'">true</IsShippingDataPlaneLibrary>

<EnableClientSdkAnalyzers Condition="'$(IsShippingClientLibrary)' == 'true'">true</EnableClientSdkAnalyzers>
<EnableFxCopAnalyzers Condition="'$(IsShippingClientLibrary)' == 'true'">true</EnableFxCopAnalyzers>
<EnableStyleCopAnalyzers Condition="'$(EnableStyleCopAnalyzers)' == '' and '$(IsClientLibrary)' == 'true'">true</EnableStyleCopAnalyzers>
Expand All @@ -65,7 +73,7 @@
</PropertyGroup>

<!-- TODO. REVIEW -->
<PropertyGroup Condition="'$(IsMgmtClientLibrary)' == 'true'">
<PropertyGroup Condition="'$(IsMgmtLibrary)' == 'true'">
<NoWarn>
$(NoWarn);
CA1812; <!-- Avoid uninstantiated internal classes. (Result from below including the Azure.Core source) -->
Expand Down Expand Up @@ -109,7 +117,7 @@
<RequiredTargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net461;netcoreapp2.1;netcoreapp3.1;net5.0</RequiredTargetFrameworks>
</PropertyGroup>

<Import Project="$(RepoRoot)/sdk/core/Azure.Core/src/Azure.Core.props" Condition="'$(IsMgmtClientLibrary)' == 'true'"/>
<Import Project="$(RepoRoot)/sdk/core/Azure.Core/src/Azure.Core.props" Condition="'$(IsMgmtLibrary)' == 'true'"/>
<Import Project="TestFramework.props" Condition="'$(IsTestProject)' == 'true'"/>

<PropertyGroup>
Expand Down Expand Up @@ -173,6 +181,7 @@
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)AzSdkTestLibKey.snk</AssemblyOriginatorKeyFile>
<!-- Disable doc comments for test projects -->
<DocumentationFile></DocumentationFile>
<RunSettingsFilePath>$(RepoEngPath)\nunit.runsettings</RunSettingsFilePath>
</PropertyGroup>

<PropertyGroup Condition="'$(IsPerfProject)' == 'true' or '$(IsStressProject)' == 'true'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</Target>

<!-- Set PackageProjectUrl and PackageReleaseNotes to the package README.md and CHANGELOG.md respectively for DataPlane Libraries -->
<Target Name="SetPackageProjectUrlandReleaseNotes" BeforeTargets="GenerateNuspec" DependsOnTargets="InitializeSourceControlInformationFromSourceControlManager" Condition="'$(IsShippingDataPlaneLibrary)' == 'true' and '$(SourceRevisionId)' != ''">
<Target Name="SetPackageProjectUrlandReleaseNotes" BeforeTargets="GenerateNuspec" DependsOnTargets="InitializeSourceControlInformationFromSourceControlManager" Condition="'$(IsShippingLibrary)' == 'true' and '$(SourceRevisionId)' != ''">
<Error Condition="'$(IsClientLibrary)' == 'true' and '$(PackageReleaseNotes)' != ''" Text="Do NOT set PackageReleaseNotes property in the project. Release notes are added automatically from package changelog" />
<PropertyGroup>
<PackageRootPath>$([MSBuild]::NormalizeDirectory($(MSBuildProjectDirectory)/../))</PackageRootPath>
Expand All @@ -24,7 +24,7 @@
</Target>

<!-- Validates that there is a release note entry for the current package version -->
<Target Name="ValidateReleaseNotes" BeforeTargets="SetPackageProjectUrlandReleaseNotes" Condition="'$(IsShippingDataPlaneLibrary)' == 'true'" >
<Target Name="ValidateReleaseNotes" BeforeTargets="SetPackageProjectUrlandReleaseNotes" Condition="'$(IsShippingLibrary)' == 'true'" >
<PropertyGroup>
<ValidateReleaseNotesScriptPath Condition=" '$(ValidateReleaseNotesScriptPath)'=='' ">$(MSBuildThisFileDirectory)common/scripts/Verify-ChangeLog.ps1</ValidateReleaseNotesScriptPath>
<ChangeLogPath>$([MSBuild]::NormalizeDirectory($(MSBuildProjectDirectory)/../))CHANGELOG.md</ChangeLogPath>
Expand Down Expand Up @@ -113,7 +113,7 @@

<Import Project="TestFramework.targets" Condition="'$(IsTestProject)' == 'true'"/>

<Import Project="Azure.Management.Test.targets" Condition="'$(IsMgmtClientLibrary)' == 'true' and '$(IsTestProject)' == 'true'" />
<Import Project="Azure.Management.Test.targets" Condition="'$(IsMgmtLibrary)' == 'true' and '$(IsTestProject)' == 'true'" />

<!-- CentralPackageVersions properties -->
<PropertyGroup>
Expand All @@ -140,7 +140,7 @@
</ItemGroup>

<!-- *********** Management Client Library Override section ************* -->
<ItemGroup Condition="'$(IsMgmtClientLibrary)' == 'true' and '$(IsTestProject)' != 'true'">
<ItemGroup Condition="'$(IsMgmtLibrary)' == 'true' and '$(IsTestProject)' != 'true'">
<PackageReference Include="System.Text.Json" />

<!-- TODO: Review these file references-->
Expand All @@ -156,7 +156,7 @@
</ItemGroup>

<!-- Management Client TEST Project Specific Overrides -->
<ItemGroup Condition="'$(IsMgmtClientLibrary)' == 'true' and '$(IsTestProject)' == 'true'">
<ItemGroup Condition="'$(IsMgmtLibrary)' == 'true' and '$(IsTestProject)' == 'true'">
<ProjectReference Include="$(AzureCoreTestFramework)" />
<PackageReference Include="Azure.Identity" />
<PackageReference Include="NUnit" />
Expand All @@ -182,7 +182,7 @@

<!-- Added layer of checks to make sure release packages don't have preview dependencies -->
<Target Name="VerifyProjectReferencesReferences" Condition="'$(HasReleaseVersion)' == 'true' AND '$(IsPackable)' == 'true'" BeforeTargets="GenerateNuspec">

<Msbuild
Projects="@(_ProjectReferencesFromAssetsFile)"
Targets="_GetProjectVersion"
Expand Down Expand Up @@ -223,7 +223,7 @@
<PackageDownload Include="$(PackageId)" Version="[$(ApiCompatVersion)]" />
<PackageReference Include="Microsoft.DotNet.ApiCompat" PrivateAssets="all" />
</ItemGroup>

<Target Name="_ResolveResolvedMatchingContract" BeforeTargets="ValidateApiCompatForSrc" Condition="'$(ApiCompatVersion)' != ''">
<ItemGroup>
<_ReferencePathDirectories Include="@(ReferencePath -> '%(RootDir)%(Directory)')" />
Expand Down
2 changes: 1 addition & 1 deletion eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<PackageReference Update="OpenTelemetry" Version="1.0.1" Condition="'$(MSBuildProjectName)' == 'Azure.Monitor.OpenTelemetry.Exporter'" />
</ItemGroup>

<!--
<!--
Dependency versions for Track 2, Microsoft.* libraries.
These are dependencies for Track 2 integration packages
-->
Expand Down
16 changes: 0 additions & 16 deletions sdk/Directory.Build.props

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsDataPlaneProject>true</IsDataPlaneProject>
<ImportRepoCommonSettings>true</ImportRepoCommonSettings>
</PropertyGroup>
<!--
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props
Expand Down
1 change: 1 addition & 0 deletions sdk/core/System.Memory.Data/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsClientLibrary>true</IsClientLibrary>
<ImportRepoCommonSettings>true</ImportRepoCommonSettings>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
Expand Down
3 changes: 2 additions & 1 deletion sdk/keyvault/samples/keyvaultproxy/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<ImportRepoCommonSettings>true</ImportRepoCommonSettings>
<IsClientLibrary>true</IsClientLibrary>
</PropertyGroup>

Expand All @@ -13,7 +14,7 @@
$(NoWarn);
AZC0001
</NoWarn>
<IsShippingDataPlaneLibrary>false</IsShippingDataPlaneLibrary>
<IsShippingLibrary>false</IsShippingLibrary>
</PropertyGroup>

<!-- If building within the Azure/azure-sdk-for-net repo -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<ItemGroup>
<ProjectReference Include="$(AzureCoreTestFramework)" />
<ProjectReference Include="..\src\Microsoft.Azure.Management.MachineLearningServices.csproj" />
<ProjectReference Include="..\src\Azure.ResourceManager.MachineLearningServices.csproj" />
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" VersionOverride="$(MgmtAutorestVersion)" PrivateAssets="All" />
</ItemGroup>
</Project>
3 changes: 1 addition & 2 deletions sdk/mgmtcommon/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsMgmtProject Condition="'$(IsMgmtProject)' == ''">true</IsMgmtProject>
<IsDataPlaneProject Condition="'$(IsDataPlaneProject)' == ''">false</IsDataPlaneProject>
<IsLegacyMgmtProject Condition="'$(IsLegacyMgmtProject)' == ''">true</IsLegacyMgmtProject>
</PropertyGroup>
<PropertyGroup>
<SkipBaselineTargetFxMatching>true</SkipBaselineTargetFxMatching>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ImportRepoCommonSettings>true</ImportRepoCommonSettings>
<IsClientLibrary>true</IsClientLibrary>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<!--
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props
-->
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsClientLibrary>true</IsClientLibrary>
<IsDataPlaneProject>true</IsDataPlaneProject>
<IsTestProject>true</IsTestProject>
<Nullable>Enable</Nullable>
</PropertyGroup>

<Import Project="$(RepoEngPath)\Directory.Build.Data.props" />

<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<RootNamespace>Azure.MixedReality.Authentication.Tests</RootNamespace>
</PropertyGroup>
Expand Down
15 changes: 7 additions & 8 deletions sdk/search/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\Directory.Build.props" />
<Choose>
<When Condition="'$(IsDataPlaneProject)' == 'true'">
<PropertyGroup>
<DocumentationFile>$(IntermediateOutputPath)$(TargetFramework)\$(MSBuildProjectName).xml</DocumentationFile>
</PropertyGroup>
</When>
</Choose>
<!--
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props
-->
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />
<PropertyGroup>
<DocumentationFile>$(IntermediateOutputPath)$(TargetFramework)\$(MSBuildProjectName).xml</DocumentationFile>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions sdk/testcommon/Azure.Graph.Rbac/src/Azure.Graph.Rbac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<PackageId>Azure.Graph.Rbac</PackageId>
<Description>Azure management client SDK for Azure resource provider Microsoft.ResourceGraph</Description>
<PackageTags>azure;management;resourcegraph</PackageTags>
<!--Need explicitly specify IsMgmtClientLibrary
<!--Need explicitly specify IsMgmtLibrary
as this project doesn't start with Azure.Management-->
<IsMgmtClientLibrary>true</IsMgmtClientLibrary>
<IsMgmtLibrary>true</IsMgmtLibrary>
<NoWarn>$(NoWarn);AZC0001;AZC0008;AZC0012;CS1591</NoWarn>
</PropertyGroup>
</Project>

0 comments on commit 0c7110c

Please sign in to comment.