Replies: 4 comments 18 replies
-
Hi @leusbj. A very concise summary of the situation and useful cross-reference to the You are right in that the idea of disabling a single package by defining the version number as '' was not intended as a feature. I think it would be better to build up the list of Although, in most cases, I don't see this being something that would be used, I feel it isn't a major addition to the design. The original ability to turn the packages off at all, was largely from CPM systems, or if you used a I don't think there is any real need to split the build up from the inclusion - especially if the whole thing can be turned off or an exclude group were available. I think we will continue to use properties to set the default version numbers so there is no need. The whole SDK is designed only for .NET Framework 4.x so I don't know if there are any requirements to guard this. As for the minimum In the future, if we move to requiring a newer |
Beta Was this translation helpful? Give feedback.
-
For Centralized Version Tooling awareness, something like the following could be incorporated after the Microsoft.NET.Sdk/Sdk.targets... so that it is after the Directory.Build.targets. It can:
###Common.DefaultPackages.Versions.targets <PropertyGroup>
<SystemWebSdkProvidedPackageVersionDefaultWarningBeforeTargets>
$(SystemWebSdkProvidedPackageVersionDefaultWarningBeforeTargets);
ResolvePackageAssets
</SystemWebSdkProvidedPackageVersionDefaultWarningBeforeTargets>
</PropertyGroup>
<Target Name="SystemWebSdkProvidedPackageVersionDefaultWarning" BeforeTargets="$(SystemWebSdkProvidedPackageVersionDefaultWarningBeforeTargets)"
Condition=" '$(DisableSystemWebSdkExplicitPackageReference)'!='true' AND '$(SystemWebSdkPackageReferenceVersionToolingTargets)' != '' AND @(SystemWebSdkProvidedPackageVersionDefault->Count()) != 0 ">
<Warning
Text="The PackageReference '%(SystemWebSdkProvidedPackageVersionDefault.Identity)' was included by the SystemWeb Sdk defaulting to Version='%(SystemWebSdkProvidedPackageVersionDefault.Version)'. Centralized management of package versions was detected, consider adding this entry '%(SystemWebSdkProvidedPackageVersionDefault.Suggestion)' to your centralized package version listing."
File="%(SystemWebSdkProvidedPackageVersionDefault.ReferencedFile)"
/>
</Target>
<!-- CPV sets the EnableCentralPackageVersions property to false under certain circumstances... like file not present or if CPM is detected -->
<PropertyGroup Condition=" '$(UsingMicrosoftCentralPackageVersionsSdk)' == 'true' AND '$(EnableCentralPackageVersions)' != 'false'">
<SystemWebSdkPackageReferenceVersionToolingTargets>MSBuild.SDK.SystemWeb.Common.DefaultPackages.Versions.CPV.targets</SystemWebSdkPackageReferenceVersionToolingTargets>
</PropertyGroup>
<!-- CPM uses this same conditional to decide if CPM is really being used... checking for both the property and the file was consumed -->
<PropertyGroup Condition=" '$(ManagePackageVersionsCentrally)' == 'true' AND '$(CentralPackageVersionsFileImported)' == 'true'">
<SystemWebSdkPackageReferenceVersionToolingTargets>MSBuild.SDK.SystemWeb.Common.DefaultPackages.Versions.CPM.targets</SystemWebSdkPackageReferenceVersionToolingTargets>
</PropertyGroup>
<!-- Incorporate the appropriate logic based on the tooling detected CPM or CPV -->
<Import project="$(SystemWebSdkPackageReferenceVersionToolingTargets)" Condition=" '$(SystemWebSdkPackageReferenceVersionToolingTargets)' != '' AND Exists('$(SystemWebSdkPackageReferenceVersionToolingTargets)')"/>
Then add two files to other common files to the solution... one for CPM and one for CPV that
Common.DefaultPackages.Versions.CPM.targets <PropertyGroup>
<ApplySDKDefaultPackageVersions>false</ApplySDKDefaultPackageVersions>
</PropertyGroup>
<ItemGroup>
<!-- Find any PackageReferences added by this SDK, and provide Version when using Central Package Management -->
<!-- Start with PackageReferences so looking at only those actually referenced, filter to only those added by this Sdk and Exclude items already present to avoid duplicates -->
<PackageVersion
Include="@(PackageReference->WithMetadataValue('SystemWebSdkIncludedPackage','true')->HasMetadata('SystemWebSdkSuggestedVersion'))"
Exclude="@(PackageVersion)">
<SystemWebSdkProvidedDefaultVersion>true</SystemWebSdkProvidedDefaultVersion>
<Version>%(SystemWebSdkSuggestedVersion)</Version>
</PackageVersion>
</ItemGroup>
<ItemGroup>
<!-- Gether up entries for which this Sdk set the version metadata so Warnings can be emitted later-->
<SystemWebSdkProvidedPackageVersionDefault
Include="@(PackageVersion->HasMetadata('SystemWebSdkProvidedDefaultVersion')->WithMetadataValue('SystemWebSdkProvidedDefaultVersion','true'))"
>
<Suggestion><PackageVersion Include="%(Identity)" Version="%(Version)" /></Suggestion>
<ReferencedFile>$(DirectoryPackagesPropsPath)</ReferencedFile>
</SystemWebSdkProvidedPackageVersionDefault>
</ItemGroup>
Common.DefaultPackages.Versions.CPV.targets <PropertyGroup>
<ApplySDKDefaultPackageVersions>false</ApplySDKDefaultPackageVersions>
</PropertyGroup>
<ItemGroup>
<!-- Find any PackageReferences added by this SDK, and provide Version when using Central Package Versions -->
<!-- Start with PackageReferences so looking at only those actually referenced, filter to only those added by this Sdk, update Version property only when still not set by actual CPV file -->
<PackageReference
Update="@(PackageReference->WithMetadataValue('SystemWebSdkIncludedPackage','true')->HasMetadata('SystemWebSdkSuggestedVersion'))"
>
<SystemWebSdkProvidedDefaultVersion Condition="'%(Version)' == '' ">true</SystemWebSdkProvidedDefaultVersion>
<Version Condition="'%(Version)' == '' ">%(SystemWebSdkSuggestedVersion)</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<!-- Gether up entries for which this Sdk set the version metadata so Warnings can be emitted later-->
<SystemWebSdkProvidedPackageVersionDefault
Include="@(PackageReference->HasMetadata('SystemWebSdkProvidedDefaultVersion')->WithMetadataValue('SystemWebSdkProvidedDefaultVersion','true'))"
>
<Suggestion><PackageReference Update="%(Identity)" Version="%(Version)" /></Suggestion>
<ReferencedFile>$(CentralPackagesFile)</ReferencedFile>
</SystemWebSdkProvidedPackageVersionDefault>
</ItemGroup>
<PropertyGroup>
<SystemWebSdkProvidedPackageVersionDefaultWarningBeforeTargets>
$(SystemWebSdkProvidedPackageVersionDefaultWarningBeforeTargets);
CheckPackageReferences
</SystemWebSdkProvidedPackageVersionDefaultWarningBeforeTargets>
</PropertyGroup>
|
Beta Was this translation helpful? Give feedback.
-
See #59 for a slight tweak to logic that may be needed for one of the common packages. |
Beta Was this translation helpful? Give feedback.
-
@leusbj Have you moved forward with any of this? I know you still have the original PR open, but wondered if you planned on updating it with the results of this discussion, or if you want me to take a stab at bringing it all together? |
Beta Was this translation helpful? Give feedback.
-
During evaluation of Pull Request several discussion points arose that should have some discussion before being incorporated into this Sdk.
Let's use this forum to discuss the best way to incorporate certain desirable PackageReference items. And choose the mechanism that combines backward compatibility with this Sdk's existing control properties, providing reasonable values for the
Version
metadata attribute even when centralized versioning is being utilized by a consuming project repo (Both CentralPackageVersioning as well as CentralPackageManagement), and potentially following patterns found in Microsoft.NET.Sdk props/targets files.Version
metadataPackageReference
via a named Property. This means the adjustment can set just about anywhere in the project repo (the project file itself, Directory.Build.props, or Directory.Build.targets, or many other mechanisms) even when not using centralized versioning since Property Evaluation is calculated prior to ItemGroup evaluation.Action:
Maintain this capability, both from backward compatibility for consuming projects as they upgrade, as well as it is an easier mechanism for consuming projects rather than making them edit/update an ItemGroup.
Action:
This seems to be an unintended side-effect rather than a feature, and can/should be removed going forward?
Microsoft.NET.Sdk.BeforeCommon.targets
snippet below uses a temporary ItemGroup to accumulate References that should be included into the project.Action:
Similarly this Sdk should collect those packages that should eventually be added to the well known
PackageReference
ItemGroupMicrosoft.NET.Sdk.BeforeCommon.targets
snippet below occurs "after" the project file, so it can prevent duplication by removing items from the temporary ItemGroup that were directly included by the project file prior to adding items into the well known ItemGroup.Action:
Similarly this Sdk can/should prevent duplicates by incorporating items into the well known
PackageReference
ItemGroup "after" the project file and "before" the Microsoft.NET.Sdk/Sdk.targets. Is there preference to accumulate these items "early" in a props file, or would it be fine to accumulate them "immediately" before including them into the well known group like is done inMicrosoft.NET.Sdk.BeforeCommon.targets
?Microsoft.NET.Sdk.BeforeCommon.targets
snippet below includes guard conditions to take action only when building a .NETFramework project.Action:
However unlikely that anyone would use this Sdk to attempt to build a "Standard" or "Core" app, it wouldn't hurt to include similar protection into this Sdk's implementation, but is there any desire to add this?
Microsoft.NET.Sdk.BeforeCommon.targets
snippet below uses some logic for build Compatibility against previous versions of .NETFramework (as certain dlls were incorporated with different versions of the Framework).Action:
Only 4.6.2+ is still "In Support" and for the most part the "OOB" VS Project templates for Web Application Projects have been consistent since that time. Is there any desire to do any Framework Version checking prior to incorporating certain packages?
Version
metadata attribute of certain packages to prevent the Centralized Versioning tooling from generating errors about setting it directly when Centralized Versioning is in place.Action:
This Sdk should detect which Centralized Versioning mechanism is being used and provide the
Version
metadata in the appropriate style to match the detected mechanism (careful not to duplicate/overwrite anyVersion
properties provided by the project repo).By applying
Version
metadata "after" Microsoft.NET.Sdk/Sdk.targets (and thus after the packages have been included in the well knownPackageReference
ItemGroup), this Sdk can detect theVersion
applied by the in place Centralized Versioning tooling, and can avoid overriding or duplicating any rules already in place by the project repo.This Sdk should provide Messaging (Not Build Failures) that it has detected Centralized Versioning tooling, and did provide a default, but that project repo owner should consider explicitly adding
Version
metadata for specific packages into the right place. Poposed Message would be like "The PackageReference '{PackageName}' was included by the SystemWeb Sdk defaulting to Version='{DefaultVersionApplied}'. Centralized management of package versions was detected, consider adding this entry '{Tooling Specific Verbiage}' to your centralized package version listing." with a link to the appropriate fileMicrosoft.NET.Sdk.BeforeCommon.targets
has an example/basis from which we could start.Looking for any feedback and comments
Beta Was this translation helpful? Give feedback.
All reactions