UWP Create sideload page build - errors for unrelated projects
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 141
Description
Hi,
I am having a lot of trouble on this time consuming process where creating UWP (sideloaded/upload) packages, it fails a lot of times. I have tried to do the following steps to reduce the likelyhood of other factors playing a role in the problem:
1. Close Visual Studio, delete obj and bin folders and retry.
2. Create new Solution Configuration "ReleaseUwp" for both x64 and x86 that only builds and deploys the packages that are needed. (only solution configuration, not project configuration, this remains "Release").
3. Make sure Rebuild Solution works for both ReleaseUwp for both x86 and x64.
4. Double check that the correct architecture is selected for all the projects that are referenced.
I will not start complaining about the build times of the release building that takes more then 10 minutes, but just focus on the actual problem.
This is how the Solution Configuration is showing. The errors start to appear when I try to build a x64 release via the Publish => Create App Packages

The problem seems that it is trying to build projects that are not selected in the Solution Configuration. For example currently the project `Babywatcher.App.AndroidApp` is not building successfully in x64 architecture (or it uses AnyCpu, that is not clear). Although I didn't select that project in the Solution Configuration, it still throws errors.
A complete log file (set to Normal) when I build the ReleaseUwp on x64 via Solution -> Rebuild Solution. See [logsnormalbuild.txt](https://github.com/microsoft/msbuild/files/3841524/logsnormalbuild.txt)
A complete log file (set to Normal) when I build via Publish -> Create App Packages. See
[logspublishbuild.txt](https://github.com/microsoft/msbuild/files/3845505/logspublishbuild.txt)
I have used the following configuration on the publish page:

And here are the error messages I am getting:
I got this error in one of the previous builds:
```
Severity Code Description Project File Line Suppression State Suppression State
Error The "FilterAssemblies" task failed unexpectedly.
System.IO.FileNotFoundException: Could not find file 'C:\Users\Ruud\source\repos\Babywatcher\Babywatcher.App.Core\bin\x64\Release\netstandard2.0\Babywatcher.App.Core.dll'.
File name: 'C:\Users\Ruud\source\repos\Babywatcher\Babywatcher.App.Core\bin\x64\Release\netstandard2.0\Babywatcher.App.Core.dll'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Xamarin.Android.Tasks.FilterAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Babywatcher.App.WindowsApp.Package C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 521
```
I have got this error in the last build:
```
Severity Code Description Project File Line Suppression State Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate' (defined in assembly 'Microsoft.WindowsAzure.MediaServices.Client.Common.Authentication, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.17.2.31801, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
at Mono.Linker.Steps.MarkStep.InitializeFields(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Babywatcher.App.WindowsApp.Package C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 2106
```
In red I have marked a few projects that are not selected in the Solution Configuration.

As you can see I am getting `Xamarin\Android` related errors, which are currently, certainly, not in the selected projects's dependencies. All the selected projects besides the `WindowsApp` `WindowsApp.Package` and `WindowsApp.Bridge` are all .net standard packages and don't have a reference to Xamarin.
And to end up with a mind-blown statement: When I ONLY select x64 during publish, I was able to create a package successfully! So can it be an issue when building for both x86 and x64 after each other?
Project file of the UWP Package app, the main executable.
```xml
15.0
Debug
x86
Release
x86
Debug
x64
Release
x64
Debug
ARM
Release
ARM
Debug
ARM64
Release
ARM64
Debug
AnyCPU
Release
AnyCPU
$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\
1237cc88-54c8-4a2d-9f89-80a51c10a0f6
10.0.18362.0
10.0.18362.0
en-US
True
..\Babywatcher.App.WindowsApp\Babywatcher.App.WindowsApp.csproj
6639BBE133D83874A563605D6088A272539C3D35
False
True
x86|x64
0
OnApplicationRun
False
http://sha256timestamp.ws.symantec.com/sha256/timestamp
SHA256
True
0
Always
en
Always
en
Always
en
Always
en
Always
en
Always
en
Always
en
Always
en
Always
en
Always
en
Designer
```
Directory contents:

Command line
See log file for this, I don't know which of the 1000 commands you are looking for
### Expected behavior
I would expect that only the selected projects within the Solution Configuration are being build when creating an UWP package.
### Actual behavior
It seems that other projects are also being build when creating UWP packages.
### Environment data
`msbuild /version` output:
Microsoft (R) Build Engine version 4.8.3752.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
4.8.3752.0
OS info:
Windows 10 1903. OS build: 18362.418
If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
Visual Studio v16.3.8
dotnet --info output:
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100\
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
1.1.13 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.2.105 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
All .net Standard projects are build against v2.0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.