Skip to content

Commit 3b5f31f

Browse files
bmehta001Copilot
andcommitted
Align WinML support after main rebase
Lower remaining WinML build targets to the GA minimum, keep the C# bootstrap logic single-sourced, and auto-enable C++ bootstrap when the WinML bootstrap DLL is present. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 18572f2 commit 3b5f31f

5 files changed

Lines changed: 27 additions & 15 deletions

File tree

.pipelines/templates/build-core-steps.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ steps:
5858
inputs:
5959
command: restore
6060
projects: '$(nsRoot)/src/FoundryLocalCore/Core/Core.csproj'
61-
restoreArguments: '-r ${{ parameters.flavor }} /p:Platform=${{ parameters.platform }} /p:IncludeWebService=true /p:Configuration=Release /p:NetTargetFramework=net9.0-windows10.0.26100.0 /p:UseWinML=true'
61+
restoreArguments: '-r ${{ parameters.flavor }} /p:Platform=${{ parameters.platform }} /p:IncludeWebService=true /p:Configuration=Release /p:NetTargetFramework=net9.0-windows10.0.18362.0 /p:UseWinML=true'
6262
feedsToUse: config
6363
nugetConfigPath: '$(nsRoot)/nuget.config'
6464

@@ -67,14 +67,14 @@ steps:
6767
inputs:
6868
command: build
6969
projects: '$(nsRoot)/src/FoundryLocalCore/Core/Core.csproj'
70-
arguments: '--no-restore -r ${{ parameters.flavor }} -f net9.0-windows10.0.26100.0 /p:Platform=${{ parameters.platform }} /p:IncludeWebService=true /p:Configuration=Release /p:NetTargetFramework=net9.0-windows10.0.26100.0 /p:UseWinML=true'
70+
arguments: '--no-restore -r ${{ parameters.flavor }} -f net9.0-windows10.0.18362.0 /p:Platform=${{ parameters.platform }} /p:IncludeWebService=true /p:Configuration=Release /p:NetTargetFramework=net9.0-windows10.0.18362.0 /p:UseWinML=true'
7171

7272
- task: DotNetCoreCLI@2
7373
displayName: 'Publish FLC AOT ${{ parameters.flavor }} (WinML)'
7474
inputs:
7575
command: publish
7676
projects: '$(nsRoot)/src/FoundryLocalCore/Core/Core.csproj'
77-
arguments: '--no-restore --no-build -r ${{ parameters.flavor }} -f net9.0-windows10.0.26100.0 /p:Platform=${{ parameters.platform }} /p:Configuration=Release /p:PublishAot=true /p:NetTargetFramework=net9.0-windows10.0.26100.0 /p:UseWinML=true'
77+
arguments: '--no-restore --no-build -r ${{ parameters.flavor }} -f net9.0-windows10.0.18362.0 /p:Platform=${{ parameters.platform }} /p:Configuration=Release /p:PublishAot=true /p:NetTargetFramework=net9.0-windows10.0.18362.0 /p:UseWinML=true'
7878
publishWebProjects: false
7979
zipAfterPublish: false
8080

@@ -84,7 +84,7 @@ steps:
8484
inputs:
8585
command: restore
8686
projects: '$(nsRoot)/test/FoundryLocalCore/Core/FoundryLocalCore.Tests.csproj'
87-
restoreArguments: '-r ${{ parameters.flavor }} /p:Platform=${{ parameters.platform }} /p:IncludeWebService=true /p:Configuration=Release /p:NetTargetFramework=net9.0-windows10.0.26100.0 /p:UseWinML=true'
87+
restoreArguments: '-r ${{ parameters.flavor }} /p:Platform=${{ parameters.platform }} /p:IncludeWebService=true /p:Configuration=Release /p:NetTargetFramework=net9.0-windows10.0.18362.0 /p:UseWinML=true'
8888
feedsToUse: config
8989
nugetConfigPath: '$(nsRoot)/nuget.config'
9090

@@ -93,7 +93,7 @@ steps:
9393
inputs:
9494
command: build
9595
projects: '$(nsRoot)/test/FoundryLocalCore/Core/FoundryLocalCore.Tests.csproj'
96-
arguments: '--no-restore -r ${{ parameters.flavor }} /p:Platform=${{ parameters.platform }} /p:IncludeWebService=true /p:Configuration=Release /p:NetTargetFramework=net9.0-windows10.0.26100.0 /p:UseWinML=true'
96+
arguments: '--no-restore -r ${{ parameters.flavor }} /p:Platform=${{ parameters.platform }} /p:IncludeWebService=true /p:Configuration=Release /p:NetTargetFramework=net9.0-windows10.0.18362.0 /p:UseWinML=true'
9797

9898
- task: DotNetCoreCLI@2
9999
displayName: 'Test FLC ${{ parameters.flavor }} (WinML)'

samples/cs/verify-winml/VerifyWinML.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net9.0-windows10.0.26100</TargetFramework>
5+
<TargetFramework>net9.0-windows10.0.18362.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

sdk/cpp/src/foundry_local_manager.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
#include <string_view>
66
#include <vector>
77
#include <memory>
8+
#include <filesystem>
9+
#include <system_error>
810

911
#include <gsl/span>
12+
#include <wil/win32_helpers.h>
1013

1114
#include "foundry_local.h"
1215
#include "foundry_local_internal_core.h"
@@ -17,6 +20,16 @@
1720

1821
namespace foundry_local {
1922

23+
namespace {
24+
bool HasWinMLBootstrapDll() {
25+
auto exePath = wil::GetModuleFileNameW(nullptr);
26+
std::error_code ec;
27+
return std::filesystem::exists(
28+
std::filesystem::path(exePath.get()).parent_path() / L"Microsoft.WindowsAppRuntime.Bootstrap.dll",
29+
ec);
30+
}
31+
} // namespace
32+
2033
std::unique_ptr<Manager, Manager::Deleter> Manager::instance_;
2134

2235
void Manager::Create(Configuration configuration, ILogger* logger) {
@@ -154,13 +167,20 @@ void Manager::Cleanup() noexcept {
154167
if (config_.web && config_.web->urls) {
155168
initReq.AddParam("WebServiceUrls", *config_.web->urls);
156169
}
170+
bool hasBootstrapSetting = false;
157171
if (config_.additional_settings) {
158172
for (const auto& [key, value] : *config_.additional_settings) {
159173
if (!key.empty()) {
174+
if (key == "Bootstrap") {
175+
hasBootstrapSetting = true;
176+
}
160177
initReq.AddParam(key, value);
161178
}
162179
}
163180
}
181+
if (!hasBootstrapSetting && HasWinMLBootstrapDll()) {
182+
initReq.AddParam("Bootstrap", "true");
183+
}
164184

165185
std::string initJson = initReq.ToJson();
166186
auto initResponse = core_->call(initReq.Command(), *logger_, &initJson);

sdk/cs/src/Detail/CoreInterop.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ internal CoreInterop(Configuration config, ILogger logger)
5959
var request = new CoreInteropRequest { Params = config.AsDictionary() };
6060
PrepareWinMLBootstrap(request);
6161

62-
#if IS_WINML
63-
// WinML builds require bootstrapping the Windows App Runtime
64-
if (!request.Params.ContainsKey("Bootstrap"))
65-
{
66-
request.Params["Bootstrap"] = "true";
67-
}
68-
#endif
69-
7062
var response = ExecuteCommand("initialize", request);
7163

7264
if (response.Error != null)

sdk/python/requirements-winml.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pydantic>=2.0.0
22
requests>=2.32.4
33
openai>=2.24.0
4-
# WinML native binary packages.
4+
# WinML native binary packages from the ORT-Nightly PyPI feed.
55
foundry-local-core-winml==1.0.0
66
onnxruntime-core==1.23.2.3
77
onnxruntime-genai-core==0.13.2

0 commit comments

Comments
 (0)