dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.24k stars 1.35k forks source link

UWP Create sideload page build - errors for unrelated projects #4919

Open Ruud-cb opened 5 years ago

Ruud-cb commented 5 years ago

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

image

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

A complete log file (set to Normal) when I build via Publish -> Create App Packages. See logspublishbuild.txt

I have used the following configuration on the publish page: image

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.<ExecuteInstantiatedTask>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.<ExecuteInstantiatedTask>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.

image

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 version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
    <VisualStudioVersion>15.0</VisualStudioVersion>
  </PropertyGroup>
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|x86">
      <Configuration>Debug</Configuration>
      <Platform>x86</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x86">
      <Configuration>Release</Configuration>
      <Platform>x86</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|ARM64">
      <Configuration>Debug</Configuration>
      <Platform>ARM64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM64">
      <Configuration>Release</Configuration>
      <Platform>ARM64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|AnyCPU">
      <Configuration>Debug</Configuration>
      <Platform>AnyCPU</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|AnyCPU">
      <Configuration>Release</Configuration>
      <Platform>AnyCPU</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup>
    <WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
  </PropertyGroup>
  <Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
  <PropertyGroup>
    <ProjectGuid>1237cc88-54c8-4a2d-9f89-80a51c10a0f6</ProjectGuid>
    <TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
    <TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
    <DefaultLanguage>en-US</DefaultLanguage>
    <AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
    <EntryPointProjectUniqueName>..\Babywatcher.App.WindowsApp\Babywatcher.App.WindowsApp.csproj</EntryPointProjectUniqueName>
    <PackageCertificateThumbprint>6639BBE133D83874A563605D6088A272539C3D35</PackageCertificateThumbprint>
    <GenerateAppInstallerFile>False</GenerateAppInstallerFile>
    <AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
    <AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
    <AppInstallerUpdateFrequency>0</AppInstallerUpdateFrequency>
    <AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
    <AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
    <AppxPackageSigningTimestampServerUrl>http://sha256timestamp.ws.symantec.com/sha256/timestamp</AppxPackageSigningTimestampServerUrl>
    <AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
    <GenerateTestArtifacts>True</GenerateTestArtifacts>
    <HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <AppxBundle>Always</AppxBundle>
    <DefaultLanguage>en</DefaultLanguage>
  </PropertyGroup>
  <ItemGroup>
    <AppxManifest Include="Package.appxmanifest">
      <SubType>Designer</SubType>
    </AppxManifest>
  </ItemGroup>
  <ItemGroup>
    <None Include="Babywatcher.App.WindowsApp.Package_TemporaryKey.pfx" />
    <Content Include="StoreManifest.xml" />
    <None Include="Babywatcher.App.WindowsApp.Package_StoreKey.pfx" />
    <Content Include="Images\LargeTile.scale-100.png" />
   <!-- a lot more images here-->
    <None Include="Package.StoreAssociation.xml" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Babywatcher.App.WindowsApp.Bridge\Babywatcher.App.WindowsApp.Bridge.csproj" />
    <ProjectReference Include="..\Babywatcher.App.WindowsApp\Babywatcher.App.WindowsApp.csproj" />
  </ItemGroup>
  <Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>

Directory contents:

image

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

Ruud-cb commented 5 years ago

I have found out that the Package page does not honor the Solution Configuration. It turns out it is going back from ReleaseUwp to normal Release and therefor seems to build my unrelated android project. When I disable the build option for the default 'Release' Solution Configuration and try again, all works fine. I guess I should move this problem elsewhere?