Skip to content

Conversation

adrastogi
Copy link
Contributor

@adrastogi adrastogi commented Oct 8, 2025

Description

There are some warnings-as-errors generated in the cs-winui project when building via the script, e.g., build.cmd x64 Release WindowsML (see below). Broadly speaking, they are related to publishing / deployment aspects of the project. This change resolves the warnings by conditioning the PublishProfile property (the sample is more oriented around local F5 on a developer device), and by enabling signing only if the developer has explicitly provided signing-related pieces. I re-built locally and verified that these no longer show up in the script output and further verified that the sample continues to function as expected.

"D:\source\WindowsAppSDK-Samples\samples\WindowsML\WindowsML-Samples.sln" (default target) (1) ->
"D:\source\WindowsAppSDK-Samples\samples\WindowsML\cs-winui\WindowsMLSample.csproj" (default target) (6) ->
(PrepareForPublish target) ->
C:\Program Files\dotnet\sdk\9.0.305\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(217,5): error
NETSDK1198: A publish profile with the name 'win-x64.pubxml' was not found in the project. Set the PublishProfile
property to a valid file name. [D:\source\WindowsAppSDK-Samples\samples\WindowsML\cs-winui\WindowsMLSample.cspro
j]

"D:\source\WindowsAppSDK-Samples\samples\WindowsML\WindowsML-Samples.sln" (default target) (1) ->
"D:\source\WindowsAppSDK-Samples\samples\WindowsML\cs-winui\WindowsMLSample.csproj" (default target) (6) ->
(_ValidateSigningCertificate target) ->
D:\source\WindowsAppSDK-Samples\packages\microsoft.windows.sdk.buildtools.msix\1.7.20250829.1\build\Microsoft.W
indows.SDK.BuildTools.MSIX.Packaging.targets(783,5): error : SigningCertificateNoCertSpecified [D:\source\Windows
AppSDK-Samples\samples\WindowsML\cs-winui\WindowsMLSample.csproj]

Target Release

1.8.2

Checklist

Note that /azp run currently isn't working for this repo.

@adrastogi adrastogi requested review from mschofie and nieubank October 8, 2025 04:47
@mschofie
Copy link
Member

mschofie commented Oct 8, 2025

But you're - essentially - disabling publishing. I imagine that this affects MSBuild.exe builds because - IIRC - they publish-on-build, but VS builds don't (since VS has an explicit 'Publish' entry point). So through VS, I would imagine that Publishing just doesn't work.

There's other samples that appear to have publishing working, could we try and follow their precedent? For example Samples\Input\cs-winui\Properties\PublishProfiles\win10-x64.pubxml exists as a publish profile - should we be doing what it's doing?

@adrastogi
Copy link
Contributor Author

So through VS, I would imagine that Publishing just doesn't work.
Did you mean through msbuild?

Correct, this is intentionally disabling publishing for the reason I mentioned in the PR description (i.e., I wasn't thinking that a developer would want to actually try to publish these samples or use them as a starting point for that since the focus is on using WinML in a particular type of application). I gave this a try, though.


In reply to: 3382233199

<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
Copy link
Contributor Author

@adrastogi adrastogi Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow what is supposed to be happening. I don't see actually see anything populated under the location below when I build through either VS or msbuild (the folder structure gets created, but no binaries there):
Samples\WindowsML\cs-winui\bin\Release\net8.0-windows10.0.22621.0\win-x64\publish

Publishing through the Visual Studio UX has things go to a different folder by default, which is Samples\WindowsML\cs-winui\bin\win-x64\publish:

Image

Running dotnet publish /p:Configuration=Release /p:PublishProfile=win-x64 seems to put things under there.
Samples\WindowsML\cs-winui\bin\Release\net8.0-windows10.0.22621.0\win-x64\publish

But then since this is a packaged app, whatever is in that folder won't be runnable anyway as it's not a package. @mschofie, I am probably holding something wrong here?

@mschofie
Copy link
Member

mschofie commented Oct 8, 2025

I wasn't thinking that a developer would want to actually try to publish these samples or use them as a starting point for that since the focus is on using WinML in a particular type of application.

For a dotnet build, publishing sounds like a great show-case/test, since we can trim and even AOT. It would be lovely if it worked.

I'm trying to buddy build at the minute, and am having problems, it looks like PublishProfile needs to be set correctly:

<PublishProfile>Properties\PublishProfiles\win-$(Platform).pubxml</PublishProfile>

But then, I'm not able to set the Platform, because the .sln doesn't allow x64.

@mschofie
Copy link
Member

mschofie commented Oct 8, 2025

But then since this is a packaged app, whatever is in that folder won't be runnable anyway as it's not a package. @mschofie, I am probably holding something wrong here?

Sorry, I missed this comment. IIUC, publishing is more-then/orthogonal to packaging, it allows you to control whether you're .Net Framework dependent or not, whether you AOT or not. There's a bunch of options that would be lovely to showcase. The 'dotnet publish' documentation explains a bit more.

TBH, given that publishing is broken because the .sln file is AnyCPU-only, then perhaps your original fix is sufficient (which will address the build breaks), and we file a separate issue to get publishing working?

@adrastogi
Copy link
Contributor Author

Filed #551 for tracking that, I'll update it as I get a better understanding of Publish. Let me know if you'd suggest any other changes to this PR.


In reply to: 3382652726

@adrastogi adrastogi requested a review from nieubank October 8, 2025 23:00
@adrastogi adrastogi merged commit 6bced4c into main Oct 9, 2025
3 checks passed
@adrastogi adrastogi deleted the user/adrastogi/cs-warning branch October 9, 2025 05:33
@adrastogi adrastogi restored the user/adrastogi/cs-warning branch October 9, 2025 16:28
adrastogi added a commit that referenced this pull request Oct 9, 2025
* Fix warnings in cs-winui project

* PR feedback (add publish profiles)

* Revert "PR feedback (add publish profiles)"

This reverts commit 340e2fd.

* Remove PublishProfile

---------

Co-authored-by: Aditya Rastogi <[email protected]>
adrastogi added a commit that referenced this pull request Oct 9, 2025
* Fix warnings in cs-winui project

* PR feedback (add publish profiles)

* Revert "PR feedback (add publish profiles)"

This reverts commit 340e2fd.

* Remove PublishProfile

---------

Co-authored-by: Aditya Rastogi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants