Skip to content

Commit

Permalink
Merge pull request #251 from novotnyllc/support-net50sdk
Browse files Browse the repository at this point in the history
Add support for the .NET 5 SDK
  • Loading branch information
clairernovotny authored Dec 6, 2020
2 parents d8a57b2 + 306b742 commit 14dec38
Show file tree
Hide file tree
Showing 28 changed files with 212 additions and 64 deletions.
7 changes: 7 additions & 0 deletions MSBuild.Sdk.Extras.sln
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UwpClassLibrary", "Tests\Uw
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "ClasslibPackTests", "Tests\ClasslibPackTests.msbuildproj", "{8DB76FFF-B050-433B-B478-1FC44DB9DF6B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfCustomControlLibraryOob", "Tests\WpfCustomControlLibraryOob\WpfCustomControlLibraryOob.csproj", "{AC00A490-8BB6-4CD5-82FD-847D5A8C2C5F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -86,6 +88,10 @@ Global
{8DB76FFF-B050-433B-B478-1FC44DB9DF6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DB76FFF-B050-433B-B478-1FC44DB9DF6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DB76FFF-B050-433B-B478-1FC44DB9DF6B}.Release|Any CPU.Build.0 = Release|Any CPU
{AC00A490-8BB6-4CD5-82FD-847D5A8C2C5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC00A490-8BB6-4CD5-82FD-847D5A8C2C5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC00A490-8BB6-4CD5-82FD-847D5A8C2C5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC00A490-8BB6-4CD5-82FD-847D5A8C2C5F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -101,6 +107,7 @@ Global
{19A683CB-8C5D-480B-8D60-30F28DA40660} = {8647C74A-083C-4EAF-B9B0-2172D4A27BFC}
{B7617E50-4107-4C19-BDCF-012CCDB22FB0} = {26026DB4-DD68-43BF-8858-15AD2016C0B2}
{8DB76FFF-B050-433B-B478-1FC44DB9DF6B} = {26026DB4-DD68-43BF-8858-15AD2016C0B2}
{AC00A490-8BB6-4CD5-82FD-847D5A8C2C5F} = {26026DB4-DD68-43BF-8858-15AD2016C0B2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {93349570-79D8-4F89-8E78-C66401620727}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The final project should look like this:
```xml
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFrameworks>net46;uap10.0.16299;tizen40</TargetFrameworks>
<TargetFrameworks>net46;uap10.0.19041;tizen8.0</TargetFrameworks>
</PropertyGroup>
</Project>
```
Expand All @@ -81,7 +81,7 @@ Then again, you might want to override the version for just one project _OR_ if
```xml
<Project Sdk="MSBuild.Sdk.Extras/2.1.2">
<PropertyGroup>
<TargetFrameworks>net46;uap10.0.16299;tizen40</TargetFrameworks>
<TargetFrameworks>net46;uap10.0.19041;tizen8.0</TargetFrameworks>
</PropertyGroup>
</Project>
```
Expand Down Expand Up @@ -200,7 +200,7 @@ Once this package is configured, you can now use any supported TFM in your `Targ

- `netstandard` (.NET Standard)
- `netcoreapp` (.NET Core App)
- `net` (.NET Framework)
- `net` (.NET 5+ & .NET Framework)
- `net35-client`/`net40-client` (.NET Framework legacy Client profile)
- `wpa` (Windows Phone App 8.1)
- `win` (Windows 8 / 8.1)
Expand Down
2 changes: 1 addition & 1 deletion Source/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup Condition="'$(IsCloudBuild)' == 'true' and '$(DisableNerdBank)'!='true'">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.2.31" PrivateAssets="All"/>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="All"/>
</ItemGroup>

</Project>
13 changes: 0 additions & 13 deletions Source/MSBuild.Sdk.Extras/Build/Core.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@
<SupportedCultures Condition="'$(SupportedCultures)' == ''">$(DefaultLanguage)</SupportedCultures>
</PropertyGroup>

<!--
Detect the SDK version. For now, we have to check the NETCoreSdkVersion
else check BundledNETCoreAppTargetFrameworkVersion property for Sdk <= 2.1.300
else Give 1.0 version since that property doesn't exist in 1.x Sdks
-->
<PropertyGroup>
<_SdkNETCoreSdkVersion>$(NETCoreSdkVersion)</_SdkNETCoreSdkVersion>
<!-- Handle SemVer version like 2.1.300-preview, since MSBuild doesn't compare versions with alpha-numeric chars! -->
<_SdkNETCoreSdkVersion Condition="$(_SdkNETCoreSdkVersion.Contains('-'))">$(_SdkNETCoreSdkVersion.Split('-')[0])</_SdkNETCoreSdkVersion>
<_SdkNETCoreSdkVersion Condition="'$(_SdkNETCoreSdkVersion)' == ''">$(BundledNETCoreAppTargetFrameworkVersion)</_SdkNETCoreSdkVersion>
<_SdkNETCoreSdkVersion Condition="'$(_SdkNETCoreSdkVersion)' == ''">1.0</_SdkNETCoreSdkVersion>
</PropertyGroup>

<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == '' OR '$(VisualStudioVersion)' &lt; '14.0'">15.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<MSBuildAllProjects Condition=" '$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0' ">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>



<PropertyGroup Condition="$(_SdkShortFrameworkProfileCount) == 1 AND $(_SdkShortFrameworkProfile.Contains('+client+'))">
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v4.0</TargetFrameworkVersion>
Expand All @@ -10,8 +16,5 @@
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v4.5</TargetFrameworkVersion>
</PropertyGroup>

<PropertyGroup>
<MSBuildAllProjects Condition=" '$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0' ">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
Package Version property for Implicit Packages included in the props file
-->
<PropertyGroup Condition="'$(ExtrasUwpMetaPackageVersion)' == ''">
<ExtrasUwpMetaPackageVersion>6.2.10</ExtrasUwpMetaPackageVersion>
<ExtrasUwpMetaPackageVersion>6.2.11</ExtrasUwpMetaPackageVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(ExtrasTizenMetaPackageVersion)' == ''">
<ExtrasTizenMetaPackageVersion>5.0.0.14562</ExtrasTizenMetaPackageVersion>
<ExtrasTizenMetaPackageVersion>8.0.0.15631</ExtrasTizenMetaPackageVersion>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -28,4 +28,9 @@
<PackageReference Update="Tizen.NET" PrivateAssets="All" Condition="'$(ExtrasImplicitPlatformPackageIsPrivate)' == 'true'"/>
</ItemGroup>

<ItemGroup Condition="'$(DisableImplicitFrameworkReferences)' != 'true' AND '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" IsImplicitlyDefined="true"/>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Condition="'$(ExtrasImplicitPlatformPackageIsPrivate)' == 'true'"/>
</ItemGroup>

</Project>
29 changes: 25 additions & 4 deletions Source/MSBuild.Sdk.Extras/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,32 @@

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk"/>

<!--
Detect the SDK version. For now, we have to check the NETCoreSdkVersion
else check BundledNETCoreAppTargetFrameworkVersion property for Sdk <= 2.1.300
else Give 1.0 version since that property doesn't exist in 1.x Sdks
-->
<PropertyGroup>
<_SdkNETCoreSdkVersion>$(NETCoreSdkVersion)</_SdkNETCoreSdkVersion>
<!-- Handle SemVer version like 2.1.300-preview, since MSBuild doesn't compare versions with alpha-numeric chars! -->
<_SdkNETCoreSdkVersion Condition="$(_SdkNETCoreSdkVersion.Contains('-'))">$(_SdkNETCoreSdkVersion.Split('-')[0])</_SdkNETCoreSdkVersion>
<_SdkNETCoreSdkVersion Condition="'$(_SdkNETCoreSdkVersion)' == ''">$(BundledNETCoreAppTargetFrameworkVersion)</_SdkNETCoreSdkVersion>
<_SdkNETCoreSdkVersion Condition="'$(_SdkNETCoreSdkVersion)' == ''">1.0</_SdkNETCoreSdkVersion>
</PropertyGroup>


<PropertyGroup>
<_ExtrasSdkWithDesktopAppSupport>5.0.100</_ExtrasSdkWithDesktopAppSupport>
<_ExtrasSdkHasDesktopAppSupport Condition="'$(_ExtrasSdkHasDesktopAppSupport)' == '' and '$([System.Version]::Parse($(_SdkNETCoreSdkVersion)).CompareTo($([System.Version]::Parse($(_ExtrasSdkWithDesktopAppSupport)))))' &gt;= '0'">true</_ExtrasSdkHasDesktopAppSupport>
<_ExtrasSdkHasDesktopAppSupport Condition="'$(_ExtrasSdkHasDesktopAppSupport)' == '' ">false</_ExtrasSdkHasDesktopAppSupport>
</PropertyGroup>


<!-- Detect if WindowsDesktop SDK is here -->
<!-- The MicrosoftWindowsDesktopSdkPath is a hook so that you can redirect to a local version of the WPF SDK targets
(ie in order to test changes locally) without modifying the .NET Core SDK itself. This should work
as long as there are no changes to Sdk.props and Sdk.targets themselves. -->
<PropertyGroup Condition="'$(MicrosoftWindowsDesktopSdkPath)' == ''">
<PropertyGroup Condition="'$(MicrosoftWindowsDesktopSdkPath)' == '' and '$(_ExtrasSdkHasDesktopAppSupport)' == 'false' ">
<!-- ToolDepsJsonGeneratorProject is set early in the main SDK and points to Sdks\Microsoft.NET.Sdk\targets\GenerateDeps\GenerateDeps.proj
We can use this to get the path for the desktop -->
<_ExtrasSdkBaseDirectory>$([System.IO.Path]::GetDirectoryName($(ToolDepsJsonGeneratorProject)))\..\..\..\</_ExtrasSdkBaseDirectory>
Expand All @@ -20,12 +41,12 @@
</PropertyGroup>


<Import Condition=" '$(_ExtrasHasDesktopSdk)' != 'true' " Project="$(MSBuildThisFileDirectory)..\Build\Workarounds.props" />
<Import Condition=" '$(_ExtrasHasDesktopSdk)' != 'true' and '$(_ExtrasSdkHasDesktopAppSupport)' == 'false'" Project="$(MSBuildThisFileDirectory)..\Build\Workarounds.props" />

<Import Condition="'$(_ExtrasHasDesktopSdk)' == 'true' " Project="$(MicrosoftWindowsDesktopSdkPath)\Microsoft.NET.Sdk.WindowsDesktop.props "/>
<Import Condition="'$(_ExtrasHasDesktopSdk)' == 'true' and '$(_ExtrasSdkHasDesktopAppSupport)' == 'false' " Project="$(MicrosoftWindowsDesktopSdkPath)\Microsoft.NET.Sdk.WindowsDesktop.props "/>

<!-- TODO: Revisit once there's a way to control this directly -->
<ItemGroup Condition="'$(ExtrasUseWindowsDesktopApp)' != 'true'">
<ItemGroup Condition="'$(ExtrasUseWindowsDesktopApp)' != 'true' and '$(_ExtrasSdkHasDesktopAppSupport)' == 'false' ">
<FrameworkReference Remove="Microsoft.WindowsDesktop.App" />
</ItemGroup>

Expand Down
7 changes: 6 additions & 1 deletion Source/MSBuild.Sdk.Extras/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
<CustomAfterMicrosoftCommonTargets>$(MSBuildThisFileDirectory)..\Build\Workarounds.targets</CustomAfterMicrosoftCommonTargets>
</PropertyGroup>

<PropertyGroup Condition=" '$(_ExtrasSdkHasDesktopAppSupport)' == 'true' ">
<!-- Set here until https://github.com/dotnet/sdk/issues/14716 is resolved -->
<ImportWindowsDesktopTargets Condition=" '$(UseWpf)' == 'true' Or '$(UseWindowsForms)' == 'true'">true</ImportWindowsDesktopTargets>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\Build\Core.targets"/>
<Import Project="$(MSBuildThisFileDirectory)..\DefaultItems\ImplicitPackages.targets"/>

<Import Project="$(CustomBeforeSdkTargets)" Condition="'$(CustomBeforeSdkTargets)' != ''"/>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk"/>

<Import Condition="'$(_ExtrasHasDesktopSdk)' == 'true' and '$(ExtrasUseWindowsDesktopApp)' == 'true' " Project="$(MicrosoftWindowsDesktopSdkPath)\Microsoft.NET.Sdk.WindowsDesktop.targets "/>
<Import Condition="'$(_ExtrasHasDesktopSdk)' == 'true' and '$(ExtrasUseWindowsDesktopApp)' == 'true' and '$(_ExtrasSdkHasDesktopAppSupport)' == 'false'" Project="$(MicrosoftWindowsDesktopSdkPath)\Microsoft.NET.Sdk.WindowsDesktop.targets "/>

<!-- Replacing build-in targets -->
<Import Project="$(MSBuildThisFileDirectory)..\Build\RIDs.targets"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net45</TargetFramework>
<ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
<UseWpf>true</UseWpf>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net45</TargetFramework>
<ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
<UseWpf>true</UseWpf>
</PropertyGroup>

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

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
<UseWpf>true</UseWpf>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net45</TargetFramework>
<ExtrasEnableWinFormsProjectSetup>true</ExtrasEnableWinFormsProjectSetup>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

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

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<ExtrasEnableWinFormsProjectSetup>true</ExtrasEnableWinFormsProjectSetup>
<ExtrasEnableUserControlDesigner>true</ExtrasEnableUserControlDesigner>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\Sdk\Sdk.props" />

<PropertyGroup>
<TargetFrameworks>net471;uap10.0;uap10.0.16299;monoandroid80;xamarinios10</TargetFrameworks>
<TargetFrameworks>net471;uap10.0;uap10.0.18362;monoandroid80;xamarinios10</TargetFrameworks>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\Sdk\Sdk.targets" />
Expand Down
2 changes: 1 addition & 1 deletion Tests/ClasslibraryAsSdk/ClasslibraryAsSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<!--<TargetFramework>uap10.0</TargetFramework>-->
<!--<TargetFrameworks>uap10.0;uap10.0.16278;monoandroid70;xamarin.ios10;xamarin.mac20</TargetFrameworks>-->
<TargetFrameworks>netstandard2.0;net46;uap10.0;uap10.0.16299;monoandroid80;xamarin.ios10;xamarin.mac20;tizen40</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net46;uap10.0;uap10.0.18362;monoandroid80;xamarin.ios10;xamarin.mac20;tizen40</TargetFrameworks>
<RuntimeIdentifiers Condition="'$(TargetFramework)' == 'netstandard2.0'">win;unix</RuntimeIdentifiers>
<ExtrasBuildEachRuntimeIdentifier Condition="'$(TargetFramework)' == 'netstandard2.0'">true</ExtrasBuildEachRuntimeIdentifier>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
Expand Down
2 changes: 1 addition & 1 deletion Tests/NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="CI Builds" value="https://myget.org/F/msbuildsdkextras/api/v3/index.json" />
<add key="CI Builds" value="https://pkgs.dev.azure.com/clairernovotny/GitBuilds/_packaging/MSBuildSdkExtras/nuget/v3/index.json" />
<add key="offline" value="%userprofile%\.nuget\packages" />
<add key="temp" value="%temp%\packages" />
</packageSources>
Expand Down
2 changes: 1 addition & 1 deletion Tests/UwpClassLibrary/UwpClassLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\Sdk\Sdk.props" />

<PropertyGroup>
<TargetFramework>uap10.0.16299</TargetFramework>
<TargetFramework>uap10.0.18362</TargetFramework>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\Sdk\Sdk.targets" />
Expand Down
2 changes: 1 addition & 1 deletion Tests/WpfApp1/WpfApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFramework>net462</TargetFramework>
<OutputType>WinExe</OutputType>
<IsPackable>false</IsPackable>
<ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
<UseWpf>true</UseWpf>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Tests/WpfApp2/WpfApp2.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFramework>net462</TargetFramework>
<OutputType>WinExe</OutputType>
<IsPackable>false</IsPackable>
<ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
<UseWpf>true</UseWpf>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Tests/WpfAppUsingSdk/WpfAppUsingSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net462</TargetFramework>
<ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
<UseWpf>true</UseWpf>
<EmbeddedResourceGeneratedCodeIsPublic>true</EmbeddedResourceGeneratedCodeIsPublic>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Tests/WpfControlLibrary/WpfControlLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<IsPackable>false</IsPackable>
<ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
<UseWpf>true</UseWpf>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\Sdk\Sdk.targets" />
Expand Down
10 changes: 10 additions & 0 deletions Tests/WpfCustomControlLibraryOob/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly:ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
54 changes: 54 additions & 0 deletions Tests/WpfCustomControlLibraryOob/CustomControl1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfCustomControlLibraryOob
{
/// <summary>
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:WpfCustomControlLibraryOob"
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:WpfCustomControlLibraryOob;assembly=WpfCustomControlLibraryOob"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
/// <MyNamespace:CustomControl1/>
///
/// </summary>
public class CustomControl1 : Control
{
static CustomControl1()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1)));
}
}
}
Loading

0 comments on commit 14dec38

Please sign in to comment.