diff --git a/WindowsAppRuntime.sln b/WindowsAppRuntime.sln index 6e50801299..09599b84f4 100644 --- a/WindowsAppRuntime.sln +++ b/WindowsAppRuntime.sln @@ -545,6 +545,16 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.Media.Capture.Projection", "dev\Projections\CS\Microsoft.Windows.Media.Capture.Projection\Microsoft.Windows.Media.Capture.Projection.csproj", "{97AB4F8D-DF7E-4BA8-9B06-E7B79AF616D6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ProjectReunion.InteractiveExperiences.TransportPackage.PackageReference", "eng\PackageReference\ProjectReunion.InteractiveExperiences\Microsoft.ProjectReunion.InteractiveExperiences.TransportPackage.PackageReference.csproj", "{EDD6D3BF-EBD9-4952-A9B7-76171031139B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BackgroundTaskBuilder", "BackgroundTaskBuilder", "{F425452A-3597-4A7A-BA0A-0C3C76A9F5CD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BackgroundTaskBuilder", "dev\BackgroundTask\BackgroundTaskBuilder\BackgroundTaskBuilder.vcxitems", "{858FA9A9-F822-4B98-84A1-FE44E2C00A5D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowsAppRuntime_UniversalBGTaskDLL", "dev\WindowsAppRuntime_UniversalBGTaskDLL\WindowsAppRuntime_UniversalBGTaskDLL.vcxproj", "{0C4405E6-029E-4363-8273-A9E1FCF057DE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.ApplicationModel.Background.Projection", "dev\Projections\CS\Microsoft.Windows.ApplicationModel.Background.Projection\Microsoft.Windows.ApplicationModel.Background.Projection.csproj", "{CF74972B-1B6F-4421-AC01-F101F7C94DAE}" + ProjectSection(ProjectDependencies) = postProject + {B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1888,6 +1898,36 @@ Global {28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|x64.Build.0 = Release|x64 {28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|x86.ActiveCfg = Release|Win32 {28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|x86.Build.0 = Release|Win32 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Debug|Any CPU.ActiveCfg = Debug|x64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Debug|Any CPU.Build.0 = Debug|x64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Debug|ARM64.Build.0 = Debug|ARM64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Debug|x64.ActiveCfg = Debug|x64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Debug|x64.Build.0 = Debug|x64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Debug|x86.ActiveCfg = Debug|Win32 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Debug|x86.Build.0 = Debug|Win32 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Release|Any CPU.ActiveCfg = Release|x64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Release|Any CPU.Build.0 = Release|x64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Release|ARM64.ActiveCfg = Release|ARM64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Release|ARM64.Build.0 = Release|ARM64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Release|x64.ActiveCfg = Release|x64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Release|x64.Build.0 = Release|x64 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Release|x86.ActiveCfg = Release|Win32 + {0C4405E6-029E-4363-8273-A9E1FCF057DE}.Release|x86.Build.0 = Release|Win32 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Debug|Any CPU.ActiveCfg = Debug|x64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Debug|ARM64.Build.0 = Debug|ARM64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Debug|x64.ActiveCfg = Debug|x64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Debug|x64.Build.0 = Debug|x64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Debug|x86.ActiveCfg = Debug|Win32 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Debug|x86.Build.0 = Debug|Win32 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Release|Any CPU.ActiveCfg = Release|x64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Release|ARM64.ActiveCfg = Release|ARM64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Release|ARM64.Build.0 = Release|ARM64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Release|x64.ActiveCfg = Release|x64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Release|x64.Build.0 = Release|x64 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Release|x86.ActiveCfg = Release|Win32 + {CF74972B-1B6F-4421-AC01-F101F7C94DAE}.Release|x86.Build.0 = Release|Win32 {1D24CC70-85B1-4864-B847-3328F40AF01E}.Debug|Any CPU.ActiveCfg = Debug|x64 {1D24CC70-85B1-4864-B847-3328F40AF01E}.Debug|Any CPU.Build.0 = Debug|x64 {1D24CC70-85B1-4864-B847-3328F40AF01E}.Debug|ARM64.ActiveCfg = Debug|arm64 @@ -2114,6 +2154,10 @@ Global {7C240089-0F22-4247-9C91-51255C8DC18B} = {6213B1A3-E854-498F-AAFA-4CFC1E71023E} {AC79B8FF-4C27-4326-AD20-BBC70059FF51} = {7C240089-0F22-4247-9C91-51255C8DC18B} {28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF} = {6759ECC6-9381-4172-89E6-853F81A03D28} + {F425452A-3597-4A7A-BA0A-0C3C76A9F5CD} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A} + {858FA9A9-F822-4B98-84A1-FE44E2C00A5D} = {F425452A-3597-4A7A-BA0A-0C3C76A9F5CD} + {0C4405E6-029E-4363-8273-A9E1FCF057DE} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A} + {CF74972B-1B6F-4421-AC01-F101F7C94DAE} = {716C26A0-E6B0-4981-8412-D14A4D410531} {1A6F936D-7350-4177-8195-146BDDFACF3B} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A} {3E7FD510-8B66-40E7-A80B-780CB8972F83} = {1A6F936D-7350-4177-8195-146BDDFACF3B} {1D24CC70-85B1-4864-B847-3328F40AF01E} = {716C26A0-E6B0-4981-8412-D14A4D410531} @@ -2138,6 +2182,7 @@ Global test\inc\inc.vcxitems*{5b2d17fe-c371-417f-860c-3d32397c2404}*SharedItemsImports = 4 test\inc\inc.vcxitems*{7c502995-59c3-483b-86ba-815985353633}*SharedItemsImports = 4 dev\ApplicationData\ApplicationData.vcxitems*{7cf52890-56fa-47e2-84fb-68ee274324b6}*SharedItemsImports = 9 + dev\BackgroundTask\BackgroundTaskBuilder\BackgroundTaskBuilder.vcxitems*{858fa9a9-f822-4b98-84a1-fe44e2c00a5d}*SharedItemsImports = 9 dev\Common\Common.vcxitems*{8828053c-d6ec-4744-8624-f8c676c2d4df}*SharedItemsImports = 9 dev\Licensing\Licensing.vcxitems*{885a43fa-052d-4b0d-a2dc-13ee15796435}*SharedItemsImports = 9 dev\PackageManager\API\PackageManager.vcxitems*{8a9a0c85-65a8-4bca-a49e-45fc4fdbc7d2}*SharedItemsImports = 9 @@ -2146,6 +2191,7 @@ Global dev\AppNotifications\AppNotifications.vcxitems*{b4824897-88e0-4927-8fb9-e60106f01ed9}*SharedItemsImports = 9 test\inc\inc.vcxitems*{b567fe2e-3a03-48d0-b2b5-760cdec35891}*SharedItemsImports = 9 dev\ApplicationData\ApplicationData.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4 + dev\BackgroundTask\BackgroundTaskBuilder\BackgroundTaskBuilder.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4 dev\Common\Common.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4 dev\DynamicDependency\API\DynamicDependency.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4 dev\Licensing\Licensing.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4 diff --git a/build/CopyFilesToStagingDir.ps1 b/build/CopyFilesToStagingDir.ps1 index 2de517a091..3c261aaac2 100644 --- a/build/CopyFilesToStagingDir.ps1 +++ b/build/CopyFilesToStagingDir.ps1 @@ -42,6 +42,12 @@ PublishFile $OverrideDir\PushNotifications-Override.json $FullPublishDir\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.WindowsAppRuntime.dll $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.WindowsAppRuntime.pdb $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.WindowsAppRuntime.lib $FullPublishDir\Microsoft.WindowsAppRuntime\ +PublishFile $FullBuildOutput\WindowsAppRuntime_UniversalBGTaskDLL\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.dll $FullPublishDir\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask\ +PublishFile $FullBuildOutput\WindowsAppRuntime_UniversalBGTaskDLL\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.pdb $FullPublishDir\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask\ +PublishFile $FullBuildOutput\WindowsAppRuntime_UniversalBGTaskDLL\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.lib $FullPublishDir\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask\ +PublishFile $FullBuildOutput\WindowsAppRuntime_UniversalBGTaskDLL\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.winmd $FullPublishDir\WindowsAppRuntime_UniversalBGTaskDLL\ + +PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.ApplicationModel.Background.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.ApplicationModel.DynamicDependency.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.ApplicationModel.WindowsAppRuntime.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppLifecycle.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\ @@ -104,6 +110,8 @@ PublishFile $FullBuildOutput\DeploymentAgent\DeploymentAgent.pdb $symbolsOutputD # Copy files to Full Nuget package (alphabetical by category) # # C#/WinRT Projections +PublishFile $FullBuildOutput\Microsoft.Windows.ApplicationModel.Background.Projection\Microsoft.Windows.ApplicationModel.Background.Projection.dll $NugetDir\lib\net6.0-windows10.0.17763.0 +PublishFile $FullBuildOutput\Microsoft.Windows.ApplicationModel.Background.Projection\Microsoft.Windows.ApplicationModel.Background.Projection.pdb $NugetDir\lib\net6.0-windows10.0.17763.0 PublishFile $FullBuildOutput\Microsoft.Windows.ApplicationModel.DynamicDependency.Projection\Microsoft.Windows.ApplicationModel.DynamicDependency.Projection.dll $NugetDir\lib\net6.0-windows10.0.17763.0 PublishFile $FullBuildOutput\Microsoft.Windows.ApplicationModel.DynamicDependency.Projection\Microsoft.Windows.ApplicationModel.DynamicDependency.Projection.pdb $NugetDir\lib\net6.0-windows10.0.17763.0 PublishFile $FullBuildOutput\Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection\Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll $NugetDir\lib\net6.0-windows10.0.17763.0 @@ -182,10 +190,13 @@ PublishFile $FullBuildOutput\DynamicDependencyLifetimeManager.ProxyStub\DynamicD # Native (not managed, AppLocal / no MSIX) PublishFile $FullBuildOutput\WindowsAppRuntime_BootstrapDLL\Microsoft.WindowsAppRuntime.Bootstrap.dll $NugetDir\runtimes\win-$Platform\native PublishFile $FullBuildOutput\WindowsAppRuntime_BootstrapDLL\Microsoft.WindowsAppRuntime.Bootstrap.pdb $NugetDir\runtimes\win-$Platform\native +PublishFile $FullBuildOutput\WindowsAppRuntime_UniversalBGTaskDLL\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.dll $NugetDir\runtimes\win-$Platform\native +PublishFile $FullBuildOutput\WindowsAppRuntime_UniversalBGTaskDLL\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.pdb $NugetDir\runtimes\win-$Platform\native # # WinMD for UWP apps PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.ApplicationModel.DynamicDependency.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.ApplicationModel.WindowsAppRuntime.winmd $NugetDir\lib\uap10.0 +PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.ApplicationModel.Background.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppLifecycle.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppNotifications.Builder.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.AppNotifications.winmd $NugetDir\lib\uap10.0 @@ -197,6 +208,7 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Secur PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.Storage.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.System.Power.winmd $NugetDir\lib\uap10.0 PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.System.winmd $NugetDir\lib\uap10.0 +PublishFile $FullBuildOutput\WindowsAppRuntime_UniversalBGTaskDLL\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.winmd $NugetDir\lib\uap10.0 # # Bootstrap Auto-Initializer Files PublishFile $FullBuildOutput\WindowsAppRuntime_BootstrapDLL\MddBootstrapAutoInitializer.cpp $NugetDir\include diff --git a/build/NuSpecs/AppxManifest.xml b/build/NuSpecs/AppxManifest.xml index 954952fd6e..a46fb8be22 100644 --- a/build/NuSpecs/AppxManifest.xml +++ b/build/NuSpecs/AppxManifest.xml @@ -25,11 +25,20 @@ + + + Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.dll + + + Microsoft.WindowsAppRuntime.dll + + + diff --git a/build/NuSpecs/WindowsAppSDK-Nuget-Native.WinRt.props b/build/NuSpecs/WindowsAppSDK-Nuget-Native.WinRt.props index 068d3d3c49..88fede76fd 100644 --- a/build/NuSpecs/WindowsAppSDK-Nuget-Native.WinRt.props +++ b/build/NuSpecs/WindowsAppSDK-Nuget-Native.WinRt.props @@ -20,6 +20,16 @@ $(MSBuildThisFileDirectory)..\..\runtimes\win10-$(_WindowsAppSDKFoundationPlatform)\native\Microsoft.WindowsAppRuntime.dll true + + $(MSBuildThisFileDirectory)..\..\lib\uap10.0\Microsoft.Windows.ApplicationModel.Background.winmd + $(MSBuildThisFileDirectory)..\..\runtimes\win10-$(_WindowsAppSDKFoundationPlatform)\native\Microsoft.WindowsAppRuntime.dll + true + + + $(MSBuildThisFileDirectory)..\..\lib\uap10.0\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.winmd + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(_WindowsAppSDKFoundationPlatform)\native\Microsoft.Windows.ApplicationModel.UniversalBGTask.dll + true + $(MSBuildThisFileDirectory)..\..\lib\uap10.0\Microsoft.Windows.AppLifecycle.winmd $(MSBuildThisFileDirectory)..\..\runtimes\win10-$(_WindowsAppSDKFoundationPlatform)\native\Microsoft.WindowsAppRuntime.dll diff --git a/build/NuSpecs/WindowsAppSDK-Nuget-Native.targets b/build/NuSpecs/WindowsAppSDK-Nuget-Native.targets index 4d3045f530..ae10941c9a 100644 --- a/build/NuSpecs/WindowsAppSDK-Nuget-Native.targets +++ b/build/NuSpecs/WindowsAppSDK-Nuget-Native.targets @@ -23,6 +23,21 @@ + + + false + Microsoft.WindowsAppRuntime.dll + + + + + + true + false + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(Platform)\native\Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.dll + + + false diff --git a/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.cpp b/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.cpp new file mode 100644 index 0000000000..cbcebc8f91 --- /dev/null +++ b/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.cpp @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include "pch.h" +#include "BackgroundTaskBuilder.h" +#include "Microsoft.Windows.ApplicationModel.Background.BackgroundTaskBuilder.g.cpp" +#include + +namespace winrt +{ + using namespace winrt::Windows::ApplicationModel::Background; + using namespace Windows::Storage; +} + +namespace winrt::Microsoft::Windows::ApplicationModel::Background::implementation +{ + void BackgroundTaskBuilder::SetTaskEntryPointClsid(winrt::guid clsId) + { + m_taskEntryPointClsid = clsId; + } + + void BackgroundTaskBuilder::Name(winrt::hstring name) + { + m_name = name; + } + + void BackgroundTaskBuilder::SetTrigger(winrt::IBackgroundTrigger trigger) + { + m_builder.SetTrigger(trigger); + } + + void BackgroundTaskBuilder::AddCondition(winrt::IBackgroundCondition condition) + { + m_builder.AddCondition(condition); + } + + winrt::BackgroundTaskRegistration BackgroundTaskBuilder::Register() + { + m_builder.Name(m_name); + m_builder.TaskEntryPoint(L"Microsoft.Windows.ApplicationModel.Background.UniversalBGTask.Task"); + winrt::BackgroundTaskRegistration taskRegistration = m_builder.Register(); + + winrt::ApplicationDataContainer localSettings = winrt::ApplicationData::Current().LocalSettings(); + auto values = localSettings.Values(); + winrt::hstring lookupId = winrt::to_hstring(taskRegistration.TaskId()); + IInspectable obj = winrt::box_value(m_taskEntryPointClsid); + values.Insert(lookupId, obj); + + return taskRegistration; + } + + winrt::BackgroundTaskRegistration BackgroundTaskBuilder::Register(winrt::hstring taskName) + { + Name(taskName); + return Register(); + } + +} diff --git a/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.h b/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.h new file mode 100644 index 0000000000..88f84a9e06 --- /dev/null +++ b/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.h @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once +#include +#include "Microsoft.Windows.ApplicationModel.Background.BackgroundTaskBuilder.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::Background::implementation +{ + struct BackgroundTaskBuilder : BackgroundTaskBuilderT + { + BackgroundTaskBuilder() = default; + void SetTaskEntryPointClsid(winrt::guid clsId); + + void SetTrigger( + winrt::Windows::ApplicationModel::Background::IBackgroundTrigger trigger + ); + + void AddCondition( + winrt::Windows::ApplicationModel::Background::IBackgroundCondition trigger + ); + + + void Name(winrt::hstring Name); + winrt::hstring Name() { return m_name; } + + winrt::Windows::ApplicationModel::Background::BackgroundTaskRegistration Register(); + winrt::Windows::ApplicationModel::Background::BackgroundTaskRegistration Register(winrt::hstring taskName); + + private: + winrt::guid m_taskEntryPointClsid; + winrt::Windows::ApplicationModel::Background::BackgroundTaskBuilder m_builder; + winrt::hstring m_name; + }; +} + +namespace winrt::Microsoft::Windows::ApplicationModel::Background::factory_implementation +{ + struct BackgroundTaskBuilder : BackgroundTaskBuilderT + { + }; +} diff --git a/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.idl b/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.idl new file mode 100644 index 0000000000..e9f1c6a32b --- /dev/null +++ b/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.idl @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +namespace Microsoft.Windows.ApplicationModel.Background +{ + [contractversion(1)] + apicontract BackgroundTaskContract{}; + + [contract(BackgroundTaskContract, 1)] + runtimeclass BackgroundTaskBuilder + { + BackgroundTaskBuilder(); + + void SetTrigger( + Windows.ApplicationModel.Background.IBackgroundTrigger trigger + ); + void SetTaskEntryPointClsid( + GUID clsId + ); + void AddCondition ( + Windows.ApplicationModel.Background.IBackgroundCondition condition + ); + + String Name{ set; get; }; + + [return_name("task")] + Windows.ApplicationModel.Background.BackgroundTaskRegistration Register(); + [return_name("task")] + Windows.ApplicationModel.Background.BackgroundTaskRegistration Register(String name); + } +} diff --git a/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.vcxitems b/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.vcxitems new file mode 100644 index 0000000000..e9dd6717f1 --- /dev/null +++ b/dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.vcxitems @@ -0,0 +1,25 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {858fa9a9-f822-4b98-84a1-fe44e2c00a5d} + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + + + diff --git a/dev/Projections/CS/Microsoft.Windows.ApplicationModel.Background.Projection/Microsoft.Windows.ApplicationModel.Background.Projection.csproj b/dev/Projections/CS/Microsoft.Windows.ApplicationModel.Background.Projection/Microsoft.Windows.ApplicationModel.Background.Projection.csproj new file mode 100644 index 0000000000..a9ad196556 --- /dev/null +++ b/dev/Projections/CS/Microsoft.Windows.ApplicationModel.Background.Projection/Microsoft.Windows.ApplicationModel.Background.Projection.csproj @@ -0,0 +1,54 @@ + + + net6.0-windows10.0.17763.0 + 10.0.17763.0 + x64;x86;arm64 + AnyCPU + false + + + + true + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + Microsoft.Windows.ApplicationModel.Background + 10.0.17763.0 + false + + + + + pdbonly + true + + + + + + + + + + + + + $(OutDir)..\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.ApplicationModel.Background.winmd + true + + + + diff --git a/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj b/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj index 7d852a3d6c..62e67cef13 100644 --- a/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj +++ b/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj @@ -100,6 +100,7 @@ + diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.cpp b/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.cpp new file mode 100644 index 0000000000..72b235117d --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.cpp @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include "pch.h" +#include "Task.h" +#if __has_include("Task.g.cpp") +#include "Task.g.cpp" +#endif + +using namespace winrt; +using namespace winrt::Windows::ApplicationModel::Background; +using namespace winrt::Windows::Storage; + +namespace winrt::Microsoft::Windows::ApplicationModel::Background::UniversalBGTask::implementation +{ + inline constexpr CLSID IID_IBackgroundTask = { 2098451764, 64786, 17358, 140, 34, 234, 31, 241, 60, 6, 223 }; + void Task::Run(winrt::Windows::ApplicationModel::Background::IBackgroundTaskInstance taskInstance) + { + winrt::hstring lookupStr = winrt::to_hstring(taskInstance.Task().TaskId()); + ApplicationDataContainer localSettings = ApplicationData::Current().LocalSettings(); + auto values = localSettings.Values(); + auto lookupobj = values.Lookup(lookupStr); + winrt::guid comClsId = winrt::unbox_value(lookupobj); + + winrt::Windows::ApplicationModel::Background::IBackgroundTask bgTask = nullptr; + winrt::hresult hr = CoCreateInstance(comClsId, nullptr, CLSCTX_LOCAL_SERVER, IID_IBackgroundTask, reinterpret_cast(&bgTask)); + bgTask.Run(taskInstance); + } +} diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.h b/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.h new file mode 100644 index 0000000000..632de00cd1 --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.h @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Task.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::Background::UniversalBGTask::implementation +{ + struct Task : TaskT + { + Task() = default; + + void Run(winrt::Windows::ApplicationModel::Background::IBackgroundTaskInstance taskInstance); + }; +} + +namespace winrt::Microsoft::Windows::ApplicationModel::Background::UniversalBGTask::factory_implementation +{ + struct Task : TaskT + { + }; +} diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.idl b/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.idl new file mode 100644 index 0000000000..bcc31e8c74 --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/Task.idl @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + + + +namespace Microsoft.Windows.ApplicationModel.Background.UniversalBGTask +{ + [default_interface] + runtimeclass Task : Windows.ApplicationModel.Background.IBackgroundTask + { + Task(); + void Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance); + } +} diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.def b/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.def new file mode 100644 index 0000000000..d04a02ea81 --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.def @@ -0,0 +1,3 @@ +EXPORTS +DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE +DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.vcxproj b/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.vcxproj new file mode 100644 index 0000000000..b8203d6a99 --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.vcxproj @@ -0,0 +1,167 @@ + + + + + + + true + true + true + {0c4405e6-029e-4363-8273-a9e1fcf057de} + Microsoft.Windows.ApplicationModel.Background.UniversalBGTask + en-US + 16.0 + false + 10.0 + 10.0 + true + true + + + + + Debug + Win32 + + + Debug + x64 + + + Debug + ARM64 + + + Release + Win32 + + + Release + x64 + + + Release + ARM64 + + + + DynamicLibrary + v143 + Unicode + false + true + + + true + true + + + false + true + false + + + + + + + + + + + + Microsoft.Windows.ApplicationModel.Background.UniversalBGTask + + + Microsoft.Windows.ApplicationModel.Background.UniversalBGTask + + + Microsoft.Windows.ApplicationModel.Background.UniversalBGTask + + + Microsoft.Windows.ApplicationModel.Background.UniversalBGTask + + + Microsoft.Windows.ApplicationModel.Background.UniversalBGTask + + + Microsoft.Windows.ApplicationModel.Background.UniversalBGTask + + + + Use + pch.h + $(IntDir)pch.pch + Level4 + %(AdditionalOptions) /bigobj + _WINRT_DLL;%(PreprocessorDefinitions) + $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) + + + Console + true + WindowsAppRuntime_UniversalBGTaskDLL.def + + + + + _DEBUG;%(PreprocessorDefinitions) + + + + + NDEBUG;%(PreprocessorDefinitions) + + + true + true + + + + + + Task.cpp + + + + + Create + + + + + + + Code + Task.cpp + + + + + + + + + false + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.vcxproj.filters b/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.vcxproj.filters new file mode 100644 index 0000000000..5ac0ee6c25 --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/WindowsAppRuntime_UniversalBGTaskDLL.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + accd3aa8-1ba0-4223-9bbe-0c431709210b + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms + + + {926ab91d-31b4-48c3-b9a4-e681349f27f0} + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/packages.config b/dev/WindowsAppRuntime_UniversalBGTaskDLL/packages.config new file mode 100644 index 0000000000..df5f654653 --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/pch.cpp b/dev/WindowsAppRuntime_UniversalBGTaskDLL/pch.cpp new file mode 100644 index 0000000000..0850baca11 --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/pch.cpp @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include "pch.h" diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/pch.h b/dev/WindowsAppRuntime_UniversalBGTaskDLL/pch.h new file mode 100644 index 0000000000..5a962aa2dc --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/pch.h @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once +#include +#include +#include +#include + +// Undefine GetCurrentTime macro to prevent +// conflict with Storyboard::GetCurrentTime +#undef GetCurrentTime + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/dev/WindowsAppRuntime_UniversalBGTaskDLL/readme.txt b/dev/WindowsAppRuntime_UniversalBGTaskDLL/readme.txt new file mode 100644 index 0000000000..312359a40d --- /dev/null +++ b/dev/WindowsAppRuntime_UniversalBGTaskDLL/readme.txt @@ -0,0 +1,27 @@ +======================================================================== + WindowsAppRuntime_UniversalBGTaskDLL Project Overview +======================================================================== + +This project demonstrates how to get started authoring Windows Runtime +classes directly with standard C++, using the Windows App SDK and +C++/WinRT packages to generate implementation headers from interface +(IDL) files. The generated Windows Runtime component binary and WinMD +files should then be bundled with the app consuming them. + +Steps: +1. Create an interface (IDL) file to define your Windows Runtime class, + its default interface, and any other interfaces it implements. +2. Build the project once to generate module.g.cpp, module.h.cpp, and + implementation templates under the "Generated Files" folder, as + well as skeleton class definitions under "Generated Files\sources". +3. Use the skeleton class definitions for reference to implement your + Windows Runtime classes. + +======================================================================== +Learn more about Windows App SDK here: +https://docs.microsoft.com/windows/apps/windows-app-sdk/ +Learn more about WinUI3 here: +https://docs.microsoft.com/windows/apps/winui/winui3/ +Learn more about C++/WinRT here: +http://aka.ms/cppwinrt/ +========================================================================