UWP publish output always in test folder
Asked Answered
H

2

8

Why is it that even though I have the build setting in Visual Studio set to Release everything I create within a side-loaded UWP distribution is placed within a folder with _test on the end? Is it because MS assumes a side-loaded app is always a test app?

I place my appxbundle files within AppCenter and I'm using AppCenter to distrubute our internal production apps to our internal employess using AppCenter.

enter image description here

Here is the main reason I'm even asking. I have tried to publish an appxbundle to the AppCenter for my employees to download and install. Problem is, these target laptops don't have the Microsoft Store installed (don't ask) so the appxbundle won't auto-install. So, when I try to install via a powershell script I can clearly see that the dependency for Microsoft.NET.Native.Runtime.2.0 isn't being met and the install fails. When I extract the appxbundle for my app I see no dependencies are included. But, if I explore the root folder that my app is published to, I can find the Microsoft.NET.Native.Runtime.2.0 is there, it's just not making it into the appxbundle file. In order to install this app on these laptops I have to enable developer mode, I have to zip up the entire published folder, send this zip file to the user, have them extract it, then have them run the powershell script within the root folder. This powershell script installs my appxbundle, cert, and includes all dependencies.

I read HERE the following:

App Center always generates an app bundle. However, Debug builds are not meant to be used for sideloading. ...and the provided .appxbundle files in the Test folder do not contain required dependencies.

Since my dependencies are not included within the appxbundle and based on what Microsoft said, it appears my app is being generated as a Debug build even though I'm selecting Release within my IDE before publishing.

Hobbema answered 17/4, 2019 at 16:2 Comment(7)
Does this have an impact on your business?Tatty
@NicoZhu-MSFT I better clarified why I'm asking the questionHobbema
Have you selected Always in the Generate app bundle listbox?Tatty
@NicoZhu-MSFT yes it's set to Always.Hobbema
The build log does say it's building for Release so I guess all this is by design, it's just confusing.Hobbema
As you said, it is by design, less documents explaining this.Tatty
What? This doesn't make any sense. Appending _Test for no reason? @PostImpatica, you should probably just open a bug in VS through the Feedback option - I also do not like magic misleading stringsThrice
D
2

Sadly it's hard-coded in the msbuild file "Microsoft.AppxPackage.Targets"

Location for VS2019 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppxPackage.Targets

enter image description here


Or as MSFT UWP Engineer Nico Zhu said in the comments: "it is by design"


See also: Customizing Visual Studio MSIX packaging project output

Downwards answered 29/7, 2021 at 13:4 Comment(2)
Yet another ingenious decision of the UWP EngineersDownwards
It's also the same for Win UI 3 projectsHusband
I
2

For anyone coming in the future, the proper way to remove the _Test suffix in the package name is by adding this to your .csproj file. It should be inside the <Project> tag

  <Target Name="SetAppxPackageTestDir" BeforeTargets="_ComputeAppxPackageOutput">
    <PropertyGroup>
      <AppxPackageNameNeutral>$(ProjectName)_$(AppxManifestIdentityVersion)</AppxPackageNameNeutral>
      <_AppxPackageConfiguration Condition="'$(Configuration)' != 'Release'">_$(Configuration)</_AppxPackageConfiguration>
      <AppxPackageName>$(AppxPackageNameNeutral)_$(Platform)$(_AppxPackageConfiguration)</AppxPackageName>
      <AppxPackageTestDir>$(AppxPackageDir)$(AppxPackageNameNeutral)$(_AppxPackageConfiguration)\</AppxPackageTestDir>
      <AppxPackageTestExternalPackagesDir>$(AppxPackageDir)$(AppxPackageNameNeutral)$(_AppxPackageConfiguration)\$(ExternalPackagesDir)</AppxPackageTestExternalPackagesDir>
    </PropertyGroup>
  </Target>

This will override the variables being set by visual studio and has the added benefit of only affecting the current project

Inept answered 20/3 at 0:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.