From 0d35279c8019ee8dd562a3899bd23b448d231cd0 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 22 May 2025 08:28:54 +0000
Subject: [PATCH 1/3] Initial plan for issue
From 33f32b03eaf0135d82133393b7090eb8cfa5bd84 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 22 May 2025 08:33:08 +0000
Subject: [PATCH 2/3] Add fix for PublishSingleFile not working with
ClassLibrary
Co-authored-by: haonanttt <186026394+haonanttt@users.noreply.github.com>
---
...Microsoft.WindowsAppSDK.Foundation.targets | 3 +
...ft.WindowsAppSDK.PublishSingleFile.targets | 56 +++++++++++++++++++
.../PublishSingleFile-ClassLibrary.md | 43 ++++++++++++++
3 files changed, 102 insertions(+)
create mode 100644 build/NuSpecs/Microsoft.WindowsAppSDK.PublishSingleFile.targets
create mode 100644 docs/Packaging/PublishSingleFile-ClassLibrary.md
diff --git a/build/NuSpecs/Microsoft.WindowsAppSDK.Foundation.targets b/build/NuSpecs/Microsoft.WindowsAppSDK.Foundation.targets
index 925af86b..c50319db 100644
--- a/build/NuSpecs/Microsoft.WindowsAppSDK.Foundation.targets
+++ b/build/NuSpecs/Microsoft.WindowsAppSDK.Foundation.targets
@@ -16,6 +16,9 @@
+
+
+
diff --git a/build/NuSpecs/Microsoft.WindowsAppSDK.PublishSingleFile.targets b/build/NuSpecs/Microsoft.WindowsAppSDK.PublishSingleFile.targets
new file mode 100644
index 00000000..fd7049db
--- /dev/null
+++ b/build/NuSpecs/Microsoft.WindowsAppSDK.PublishSingleFile.targets
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+ $(PublishDir)%(ResolvedFileToPublish.DestinationSubPath)
+
+
+
+
+
+ <_PublishItemsToCheck Include="@(ResolvedFileToPublish)"
+ Condition="'%(ResolvedFileToPublish.AssetType)' == 'runtime'
+ AND '%(ResolvedFileToPublish.RuntimeIdentifier)' != ''
+ AND $([System.String]::Copy('%(ResolvedFileToPublish.SourcePath)').Contains('%(ResolvedFileToPublish.RuntimeIdentifier)'))" />
+
+ <_MissingRuntimeFiles Include="@(_PublishItemsToCheck)"
+ Condition="!Exists('%(SourcePath)')" />
+
+
+
+
+ <_NonRIDSourcePaths Include="@(_MissingRuntimeFiles->'$([System.String]::Copy('%(SourcePath)').Replace('\%(RuntimeIdentifier)\', '\'))')">
+ %(_MissingRuntimeFiles.Identity)
+
+
+
+
+
+
+
+ %(Identity)
+
+
+
+
\ No newline at end of file
diff --git a/docs/Packaging/PublishSingleFile-ClassLibrary.md b/docs/Packaging/PublishSingleFile-ClassLibrary.md
new file mode 100644
index 00000000..8b9d5bf9
--- /dev/null
+++ b/docs/Packaging/PublishSingleFile-ClassLibrary.md
@@ -0,0 +1,43 @@
+# PublishSingleFile with ClassLibrary references
+
+## Issue
+
+When using the Windows App SDK with a project that references a class library and has `PublishSingleFile=true` set, the build process incorrectly looks for the class library in a path that includes the runtime identifier (e.g., `win-x64`), which causes build failures.
+
+For example, if your solution structure is:
+```
+Solution
+ ├── App1 (references ClassLibrary1, with PublishSingleFile=true)
+ └── ClassLibrary1
+```
+
+When publishing App1, you might encounter errors like:
+```
+Cannot resolve Assembly or Windows Metadata file 'path\to\ClassLibrary1\bin\Release\net8.0-windows10.0.19041.0\win-x64\ClassLibrary1.dll'
+Metadata file 'path\to\ClassLibrary1\bin\Release\net8.0-windows10.0.19041.0\win-x64\ClassLibrary1.dll' could not be found
+```
+
+## Solution
+
+The fix implemented in `Microsoft.WindowsAppSDK.PublishSingleFile.targets` addresses this issue by correcting the reference paths during the publish process.
+
+The target does the following:
+1. Runs before the `_ComputeResolvedFilesToPublishList` target when `PublishSingleFile=true`
+2. Identifies class library references that include runtime identifiers in their paths
+3. Checks if the files exist at the specified paths
+4. For missing files, tries to find them in the non-runtime-specific location
+5. Updates the `ResolvedFileToPublish` items with the corrected paths
+
+## Workaround (prior to this fix)
+
+If you encounter this issue before updating to a version with this fix, you can:
+
+1. Create a Blank Project
+2. Create a Blank Class Library
+3. Add Class Library Reference to Main Project
+4. Build
+5. Manually modify the Class Library output folder:
+ - Create a folder named after your runtime identifier (e.g., `win-x64`) in the output directory
+ - Copy all files from the main output directory into this new folder
+
+This mimics the file structure expected by the publish process.
\ No newline at end of file
From 4498b6e1c7711063867c3e6e61cbfcf411a55cb9 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 26 May 2025 09:37:34 +0000
Subject: [PATCH 3/3] Update fix to apply to all publish operations, not just
PublishSingleFile
Co-authored-by: haonanttt <186026394+haonanttt@users.noreply.github.com>
---
...rosoft.WindowsAppSDK.ClassLibraryPublish.targets} | 12 ++++++------
.../Microsoft.WindowsAppSDK.Foundation.targets | 4 ++--
...ssLibrary.md => WinUI-ClassLibrary-References.md} | 10 +++++-----
3 files changed, 13 insertions(+), 13 deletions(-)
rename build/NuSpecs/{Microsoft.WindowsAppSDK.PublishSingleFile.targets => Microsoft.WindowsAppSDK.ClassLibraryPublish.targets} (85%)
rename docs/Packaging/{PublishSingleFile-ClassLibrary.md => WinUI-ClassLibrary-References.md} (69%)
diff --git a/build/NuSpecs/Microsoft.WindowsAppSDK.PublishSingleFile.targets b/build/NuSpecs/Microsoft.WindowsAppSDK.ClassLibraryPublish.targets
similarity index 85%
rename from build/NuSpecs/Microsoft.WindowsAppSDK.PublishSingleFile.targets
rename to build/NuSpecs/Microsoft.WindowsAppSDK.ClassLibraryPublish.targets
index fd7049db..5fdd2c59 100644
--- a/build/NuSpecs/Microsoft.WindowsAppSDK.PublishSingleFile.targets
+++ b/build/NuSpecs/Microsoft.WindowsAppSDK.ClassLibraryPublish.targets
@@ -2,18 +2,18 @@
-
+
-
-
+
+
diff --git a/docs/Packaging/PublishSingleFile-ClassLibrary.md b/docs/Packaging/WinUI-ClassLibrary-References.md
similarity index 69%
rename from docs/Packaging/PublishSingleFile-ClassLibrary.md
rename to docs/Packaging/WinUI-ClassLibrary-References.md
index 8b9d5bf9..e4cf5379 100644
--- a/docs/Packaging/PublishSingleFile-ClassLibrary.md
+++ b/docs/Packaging/WinUI-ClassLibrary-References.md
@@ -1,13 +1,13 @@
-# PublishSingleFile with ClassLibrary references
+# WinUI ClassLibrary References During Publish
## Issue
-When using the Windows App SDK with a project that references a class library and has `PublishSingleFile=true` set, the build process incorrectly looks for the class library in a path that includes the runtime identifier (e.g., `win-x64`), which causes build failures.
+When using the Windows App SDK with a project that references a WinUI class library, the build process incorrectly looks for the class library in a path that includes the runtime identifier (e.g., `win-x64`), which causes build failures. This occurs in any publish scenario, including when using `PublishSingleFile=true`.
For example, if your solution structure is:
```
Solution
- ├── App1 (references ClassLibrary1, with PublishSingleFile=true)
+ ├── App1 (references ClassLibrary1)
└── ClassLibrary1
```
@@ -19,10 +19,10 @@ Metadata file 'path\to\ClassLibrary1\bin\Release\net8.0-windows10.0.19041.0\win-
## Solution
-The fix implemented in `Microsoft.WindowsAppSDK.PublishSingleFile.targets` addresses this issue by correcting the reference paths during the publish process.
+The fix implemented in `Microsoft.WindowsAppSDK.ClassLibraryPublish.targets` addresses this issue by correcting the reference paths during the publish process.
The target does the following:
-1. Runs before the `_ComputeResolvedFilesToPublishList` target when `PublishSingleFile=true`
+1. Runs before the `_ComputeResolvedFilesToPublishList` target during any publish operation
2. Identifies class library references that include runtime identifiers in their paths
3. Checks if the files exist at the specified paths
4. For missing files, tries to find them in the non-runtime-specific location