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

Auto set version of library packages #116

Merged
merged 9 commits into from
Aug 1, 2023
Merged
3 changes: 3 additions & 0 deletions .github/workflows/config/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<PropertyGroup>
<RepositoryDirectory>$(MSBuildThisFileDirectory)</RepositoryDirectory>
<ToolingDirectory>$(RepositoryDirectory)\tooling</ToolingDirectory>

<MajorVersion>1</MajorVersion>
<MinorVersion>0</MinorVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion ProjectHeads/App.Head.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Choose>
<When Condition="'$(ToolkitConvertersSourceProject)' == ''">
<ItemGroup>
<PackageReference Include="CommunityToolkit.$(DependencyVariant).Converters" Version="8.0.0-beta.1"/>
<PackageReference Include="CommunityToolkit.$(DependencyVariant).Converters" Version="8.0.230801-preview"/>
</ItemGroup>
</When>
<Otherwise>
Expand Down
4 changes: 1 addition & 3 deletions ProjectHeads/Head.Uwp.props
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.12</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.12"/>
<PackageReference Include="PolySharp" Version="1.13.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
3 changes: 1 addition & 2 deletions ProjectHeads/Tests.Head.WinAppSdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<Import Project="$(MSBuildThisFileDirectory)\Head.WinAppSdk.props"/>

<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.TestHost">
<Version>17.1.0</Version>
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.1.0">
<ExcludeAssets>build</ExcludeAssets>
</PackageReference>
</ItemGroup>
Expand Down
11 changes: 3 additions & 8 deletions ProjectHeads/Tests.Head.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@

<!-- Test Dependencies -->
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.2.10</Version>
</PackageReference>

<PackageReference Include="MSTest.TestFramework">
<Version>2.2.10</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10"/>
<PackageReference Include="MSTest.TestFramework" Version="2.2.10"/>

<ProjectReference Include="$(ToolingDirectory)\CommunityToolkit.Tooling.TestGen\CommunityToolkit.Tooling.TestGen.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="True" />
</ItemGroup>

<Choose>
<When Condition="'$(ToolkitExtensionSourceProject)' == ''">
<ItemGroup>
<PackageReference Include="CommunityToolkit.$(DependencyVariant).Extensions" Version="8.0.0-beta.2"/>
<PackageReference Include="CommunityToolkit.$(DependencyVariant).Extensions" Version="8.0.230801-preview"/>
</ItemGroup>
</When>
<Otherwise>
Expand Down
2 changes: 1 addition & 1 deletion ProjectTemplate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ This may require a reboot.

#### Updating NuGet Package

Packages are manually versioned right now, [see this issue here](https://github.com/CommunityToolkit/Labs-Windows/issues/133). In order to update your NuGet package, update the `<Version>` tag in your library's `CommunityToolkit.WinUI.Controls.MyExperimentNameHere.csproj` file.
Packages are automatically versioned right now by day. The first commit of the day will push a new package with that date stamp.

#### WebAssembly Sample Project

Expand Down
13 changes: 0 additions & 13 deletions ProjectTemplate/src/AdditionalAssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<PropertyGroup>
<ToolkitComponentName>ProjectTemplate</ToolkitComponentName>
<Description>This package contains ProjectTemplate.</Description>
<Version>0.0.1</Version>

<!-- Rns suffix is required for namespaces shared across projects. See https://github.com/CommunityToolkit/Labs-Windows/issues/152 -->
<RootNamespace>CommunityToolkit.WinUI.Controls.ProjectTemplateRns</RootNamespace>
Expand Down
108 changes: 108 additions & 0 deletions ToolkitComponent.SourceProject.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,114 @@
<Import Project="$(ToolingDirectory)\MultiTarget\Library.props" />

<PropertyGroup>
<Version Condition="'$(Version)' == ''">$(MajorVersion).$(MinorVersion).$([System.DateTime]::UtcNow.ToString(yyMMdd))</Version>
<Version Condition="'$(PreviewVersion)' != ''">$(Version)-$(PreviewVersion)</Version>
<PackageId Condition="'$(PackageId)' == ''">$(PackageIdPrefix).$(PackageIdVariant).$(ToolkitComponentName)</PackageId>
</PropertyGroup>

<!-- Auto Generate our own Assembly Info -->
<PropertyGroup>
<!-- Turn-off .NET based AssemblyInfo.cs generator, see below -->
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<!-- https://stackoverflow.com/questions/10980249/msbuild-task-for-setting-custom-attribute-in-assemblyinfo-cs -->
<!-- https://gist.github.com/KirillOsenkov/f20cb84d37a89b01db63f8aafe03f19b -->
<Target Name="AddAssemblyAttributes" BeforeTargets="BeforeCompile">
<PropertyGroup>
<GeneratedAssemblyInfoPath>$(IntermediateOutputPath)AssemblyInfo.g.cs</GeneratedAssemblyInfoPath>
</PropertyGroup>

<ItemGroup>
<!-- Add our own AssemblyInfo.cs standard attributes -->
<AssemblyAttributes Include="AssemblyTitle">
<_Parameter1>$(PackageId)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyDescription">
<_Parameter1>$(Description)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyCompany">
<_Parameter1>$(Company)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyProduct">
<_Parameter1>$(Product)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyCopyright">
<_Parameter1>$(Copyright)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyTrademark">
<_Parameter1></_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyCulture">
<_Parameter1></_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyConfiguration">
<_Parameter1>$(Configuration)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyVersion">
<!-- This should remain as Major.Minor as Assembly Version shouldn't change across small revisions -->
<_Parameter1>$(MajorVersion).$(MinorVersion).0.0</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyFileVersion">
<!-- TODO: We should include some build number in here to make it more unique, can't use same date as too large -->
<_Parameter1>$(MajorVersion).$(MinorVersion).0.0</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyInformationalVersion">
<_Parameter1>$(Version)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="System.Runtime.InteropServices.ComVisible">
<_Parameter1>false</_Parameter1>
<_Parameter1_TypeName>System.Boolean</_Parameter1_TypeName>
</AssemblyAttributes>

<!-- Add custom attributes, also see https://stackoverflow.com/questions/56835671/how-to-read-a-msbuild-property-in-a-given-project-in-runtime -->
<AssemblyAttributes Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(SourceRevisionId)' != ''">
<_Parameter1>CommitHash</_Parameter1>
<_Parameter2>$(SourceRevisionId)</_Parameter2>
</AssemblyAttributes>
<AssemblyAttributes Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(PackageProjectUrl)' != ''">
<_Parameter1>RepositoryUrl</_Parameter1>
<_Parameter2>$(PackageProjectUrl)</_Parameter2>
</AssemblyAttributes>
<Warning Text="The PackageProjectUrl property was not set." Condition="'$(PackageProjectUrl)' == ''" />

<!-- Add InternalsVisibleTo for tests -->
<AssemblyAttributes Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(ToolkitComponentName).Tests.Uwp</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(ToolkitComponentName).Tests.WinAppSdk</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>CommunityToolkit.Tests.Uwp</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>CommunityToolkit.Tests.WinAppSdk</_Parameter1>
</AssemblyAttributes>
</ItemGroup>

<ItemGroup Condition="'@(InternalsVisibleTo)' != ''">
<!-- Add any declared InternalsVisibleTo in source project, if any-->
<AssemblyAttributes Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>%(InternalsVisibleTo.Identity)</_Parameter1>
</AssemblyAttributes>
</ItemGroup>

<!-- Extra attributes specific to platforms -->
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
<AssemblyAttributes Include="System.Runtime.Versioning.TargetPlatformAttribute">
<_Parameter1>Windows10.0.19041.0</_Parameter1> <!-- TODO: Grab from variable -->
</AssemblyAttributes>
<AssemblyAttributes Include="System.Runtime.Versioning.SupportedOSPlatformAttribute">
<_Parameter1>Windows10.0.17763.0</_Parameter1> <!-- TODO: Grab from variable -->
</AssemblyAttributes>
</ItemGroup>

<ItemGroup>
<Compile Include="$(GeneratedAssemblyInfoPath)" />
</ItemGroup>

<!-- Write out new auto-generated AssemblyInfo.g.cs file -->
<WriteCodeFragment Language="C#" OutputFile="$(GeneratedAssemblyInfoPath)" AssemblyAttributes="@(AssemblyAttributes)" />
</Target>
</Project>