Skip to content

Commit

Permalink
Refactor Project and Build related files
Browse files Browse the repository at this point in the history
- Refactor Project files
- Refactor Markdown files
- Remove unnecessary files
- Use latest NuGet and config
- Fixup UAP/Windows TFM versions
  • Loading branch information
Nirmal4G committed Oct 27, 2022
1 parent 925b24c commit 4929dc5
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 76 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>netstandard1.4;uap10.0.19041;net461;netcoreapp3.1;net5.0;net5.0-windows10.0.17763.0;native</TargetFrameworks>
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
<TargetFrameworks>netstandard1.4;uap10.0.16299;net461;netcoreapp3.1;net5.0;net5.0-windows10.0.17763;native</TargetFrameworks>
<NuspecFile>Microsoft.Toolkit.Uwp.Notifications.nuspec</NuspecFile>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.19041'">
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<PropertyGroup Condition="$(TargetFramework.StartsWith('uap10.0')) or '$(TargetFramework)' == 'native'">
<TargetPlatformVersion>10.0.$(TargetPlatformRevision).0</TargetPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="!$(TargetFramework.StartsWith('uap10.0'))">
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0-windows10.0.17763.0'">
<!-- Define the WINDOWS_UWP conditional symbol, since the Windows.Data.Xml and the Windows.UI.Notification namespaces are available -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netcoreapp3.1' or $(TargetFramework.Contains('windows10.0'))">
<!-- Define the WINDOWS_UWP conditional symbol, since the 'Windows.Data.Xml' and the 'Windows.UI.Notification' namespaces are available -->
<DefineConstants>$(DefineConstants);WINDOWS_UWP;WIN32</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'native'">
<OutputType>winmdobj</OutputType>
<!-- Build -->
<DebugType>Full</DebugType>
<OutputType>WinMDObj</OutputType>
<AssetTargetFallback>uap10.0</AssetTargetFallback>
<!-- Targets -->
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<!-- Workaround for issue NuGet/Home#8388; change behavior during NuGet restore time vs. final build to avoid NuGet conflict in VS 2019 -->
<NuGetTargetMoniker Condition="'$(DesignTimeBuild)' == 'true'">native</NuGetTargetMoniker>
<NuGetTargetMoniker Condition="'$(DesignTimeBuild)' != 'true'">UAP,Version=v10.0</NuGetTargetMoniker>
<PackageTargetFallback>uap10.0</PackageTargetFallback>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<DefineConstants Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">$(DefineConstants);WINDOWS_UWP;WINRT</DefineConstants>
<CopyLocalLockFileAssemblies Condition="'$(CopyLocalLockFileAssemblies)' == ''">false</CopyLocalLockFileAssemblies>
<TargetFrameworkIdentifier>.NETCore</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<!-- Misc -->
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<DefineConstants>$(DefineConstants);WINDOWS_UWP;WINRT</DefineConstants>
<LanguageTargets>$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets</LanguageTargets>
<ExtrasImplicitPlatformPackageIsPrivate>true</ExtrasImplicitPlatformPackageIsPrivate>

<!-- Need to override the built-in implicit defines for UAP or it'll be NETCORE5_0. This makes it UAP10_0_10240_0 to match the rest -->
<ImplicitFrameworkDefine Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">UAP$(TargetPlatformMinVersion.Replace('.', '_'))</ImplicitFrameworkDefine>
<DisableImplicitFrameworkDefines Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">true</DisableImplicitFrameworkDefines>
<!-- Workaround for issue NuGet/Home#8388; Restore conflict in VS IDE 2019 during DesignTime vs BuildTime. -->
<NuGetTargetMoniker Condition="'$(DesignTimeBuild)' != 'true'">UAP,Version=v10.0</NuGetTargetMoniker>
<NuGetTargetMoniker Condition="'$(DesignTimeBuild)' == 'true'">Native,Version=v0.0</NuGetTargetMoniker>
</PropertyGroup>

<ItemGroup>
<None Include="Microsoft.Toolkit.Uwp.Notifications.targets" Pack="true" PackagePath="build\native" />
</ItemGroup>

<!-- In order to support .NET Native, we need to include an appropriate .rd.xml for UWP (remove from everything else) -->

<!-- Desktop Win32 apps -->
<!-- For Desktop Win32 apps' WinRT APIs support -->
<ItemGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netcoreapp3.1'">
<!-- Reference Windows SDK NuGet of correct target platform version -->
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
</ItemGroup>

<!-- The .NET Core desktop apps also need the Registry NuGet package and System.Reflection.Emit for generating COM class dynamically -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0-windows10.0.17763.0'">
<!-- The .NET Core desktop apps also need the Registry NuGet package and 'System.Reflection.Emit' for generating COM class dynamically -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or $(TargetFramework.Contains('windows10.0'))">
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
Expand All @@ -61,12 +57,15 @@
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="$(ExtrasUwpMetaPackageVersion)" PrivateAssets="All" IsImplicitlyDefined="true" />
</ItemGroup>

<!-- Native (C++) doesn't need 'System.ValueTuple' (plus it's incompatible with this package) -->
<!-- Native (C++) does not need 'System.ValueTuple' (plus it is incompatible with this package) -->
<ItemGroup Condition="'$(TargetFramework)' != 'native'">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<!-- Set the nuspec properties. Dependent on version which isn't updated till after 'GetBuildVersion'. Condition ensures we only set once since this runs multiple times for each target. -->
<!--
Set the nuspec properties. Dependent on version which is not updated till after 'GetBuildVersion'.
Condition ensures we only set once since this runs multiple times for each target.
-->
<Target Name="SetNuspecProperties" AfterTargets="GetBuildVersion">
<PropertyGroup Condition="'$(NuspecProperties)' == ''">
<NuspecProperties>buildOutput=bin\$(Configuration);version=$(Version)</NuspecProperties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@
<file src="$buildOutput$\net5.0\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\net5.0\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\net5.0\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\net5.0\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\net5.0\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\net5.0\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\net5.0-windows10.0.17763.0\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\net5.0-windows10.0.17763.0\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\net5.0-windows10.0.17763.0\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\uap10.0.19041\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\uap10.0.19041\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\uap10.0.19041\Microsoft.Toolkit.Uwp.Notifications.pri" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pri" />
<file src="$buildOutput$\uap10.0.19041\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pri" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pri" />
<file src="$buildOutput$\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\native\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\native\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\native\Microsoft.Toolkit.Uwp.Notifications.pri" target="lib\native\Microsoft.Toolkit.Uwp.Notifications.pri" />
<file src="$buildOutput$\native\Microsoft.Toolkit.Uwp.Notifications.winmd" target="lib\native\Microsoft.Toolkit.Uwp.Notifications.winmd" />
Expand Down
40 changes: 21 additions & 19 deletions Microsoft.Toolkit.Uwp.Notifications/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
Welcome to the Notifications section of the toolkit! This contains the Notifications library, including the object model for tile, toast, and badge XML (previously called NotificationsExtensions).
# UWP Notifications

Welcome to the Notifications section of the toolkit! This contains the Notifications library, including the object model for tile, toast, and badge XML (previously called `NotificationsExtensions`).

## Where should I add new code?
Any code for generating notifications should be written in the Microsoft.Toolkit.Uwp.Notifications project.

Any code for generating notifications should be written in the `Microsoft.Toolkit.Uwp.Notifications` project.

If there's UWP-specific code, use the appropriate `#ifdef`, `WINDOWS_UWP` or `WINRT`.

## What are all the projects for?
All the code is contained on the Microsoft.Toolkit.Uwp.Notifications project.

It outputs `netstandard1.4`, `uap10.0`, `native` for WinRT, and netcoreapp for .Net Core projects. The UWP library is only for C#, while the WinRT library is a Windows Runtime Component for C++.

All the code is contained on the `Microsoft.Toolkit.Uwp.Notifications` project.

| C# | C++ |
| ---------------- | ------------------- |
| NET Standard 1.4 | UWP WinRT Component |
| UWP C# DLL | |
| .Net Core DLL | |

It outputs `netstandard1.4`, `uap10.0`, `native` for WinRT, and `netcoreapp3.1` for .NET Core projects. The UWP library is only for C#, while the WinRT library is a Windows Runtime Component for C++.

| C# | C++ |
| --------------------- | ------------------- |
| .NET Standard Library | UWP WinRT Component |
| .NET Core Library | |
| UWP C# Library | |

## Scenarios we want to support

Imagine you add this library to a .NET Standard class library, and you also add it to your UWP app. In this case, your .NET Standard class library will receive the NETStandard dll. Your UWP project will receive the UWP dll.
Imagine you add this library to a .NET Standard class library, and you also add it to your UWP app. In this case, your .NET Standard class library will receive the .NET Standard DLL. Your UWP project will receive the UWP DLL.

## How are the test projects organized?

If you look in the UnitTests folder of the repo, you'll notice that there's three projects...
- UnitTests.Notifications.Shared
- UnitTests.Notifications.NetCore
- UnitTests.Notifications.UWP
- UnitTests.Notifications.WinRT
If you look in the `UnitTests` folder of the repo, you'll notice that there are three projects...

- `UnitTests.Notifications.Shared`
- `UnitTests.Notifications.NetCore`
- `UnitTests.Notifications.UWP`
- `UnitTests.Notifications.WinRT`

That's because in our source code, we have some #IF defs for switching between the different types of reflection that C# uses, since it's different between a .NET Standard and WinRT code.
That's because in our source code, we have some `#ifdef` for switching between the different types of reflection that C# uses, since it's different between a .NET Standard and WinRT code.

Therefore, there are two different code paths, one path for NETFX_CORE, and another for when that isn't present. The two test projects exercise both code paths.
Therefore, there are two different code paths, one path for `NETFX_CORE`, and another for when that isn't present. The two test projects exercise both code paths.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</PackageReference>
<!-- TODO Reintroduce graph controls
<PackageReference Include="Microsoft.Toolkit.Graph.Controls">
<Version>6.1.0-build.6</Version>
<Version>7.0.0-preview2</Version>
</PackageReference>
-->
<PackageReference Include="Microsoft.UI.Xaml">
Expand All @@ -127,7 +127,6 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<Content Include="Assets\BrushAssets\TileTexture.png" />
<Content Include="Assets\BrushAssets\NoiseTexture.png" />
<Content Include="Assets\checker.png" />
Expand Down Expand Up @@ -1493,14 +1492,14 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework and Windows SDK are automatically included -->
<SDKReference Include="Microsoft.Services.Store.Engagement, Version=10.0">
<Name>Microsoft Engagement Framework</Name>
</SDKReference>
<SDKReference Include="Microsoft.VCLibs, Version=14.0">
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
</SDKReference>
</ItemGroup>
<ItemGroup />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions Microsoft.Toolkit.Uwp.UI/Microsoft.Toolkit.Uwp.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit" Version="7.1.2" />
<ProjectReference Include="..\Microsoft.Toolkit.Uwp\Microsoft.Toolkit.Uwp.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.Toolkit.Uwp\Microsoft.Toolkit.Uwp.csproj" />
<PackageReference Include="Microsoft.Toolkit" Version="7.1.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion SmokeTests/nuget.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Local" value="..\bin\nupkg" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
6 changes: 0 additions & 6 deletions UnitTests/UnitTests.XamlIslands/Directory.Build.props

This file was deleted.

3 changes: 0 additions & 3 deletions UnitTests/UnitTests.XamlIslands/Directory.Build.targets

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup>
<AssetTargetFallback>uap10.0.19041</AssetTargetFallback>
<AssetTargetFallback>uap10.0.18362</AssetTargetFallback>
<ApplicationManifest>app.manifest</ApplicationManifest>
<StartupObject>UnitTests.XamlIslands.Program</StartupObject>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
displayName: Setup Environment Variables

- task: NuGetToolInstaller@0
displayName: Use NuGet 5.11.x
displayName: Use NuGet 5.11
inputs:
versionSpec: 5.11.x

- task: DotNetCoreCLI@2
inputs:
command: custom
Expand Down
2 changes: 1 addition & 1 deletion build/Windows.Toolkit.VisualStudio.Design.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<AppDesigner Include="Properties\"/>
<!-- The 'LogicalName' metadata changes the default manifest naming scheme -->
<!-- The 'LogicalName' metadata changes the default manifest naming scheme -->
<EmbeddedResource Include="Icons\*.icon.png" LogicalName="$(ParentProjectRootNamespace).%(Filename)%(Extension)"/>
<EmbeddedResource Include="$(ParentProjectOutputPath)$(ParentProjectName).xml" LinkBase="Properties\" LogicalName="%(Filename)%(Extension)"/>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="AzureLatest" value="https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-MainLatest/nuget/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="MUX-Shared" value="https://pkgs.dev.azure.com/ms/microsoft-ui-xaml/_packaging/MUX-Shared/nuget/v3/index.json" />
<add key="AzureLatest" value="https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-MainLatest/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down

0 comments on commit 4929dc5

Please sign in to comment.