0

I have a C# solution with VS 2017, containing an app project and a test project. I can use the "create app package" wizard to create one single bundle for x86 and x64. However, I would like to automate this process, which means I need to use msbuild in command line to do the same work.

With the reference from here and here, I got:

msbuild .\MyProject.sln /p:AppxBundle=Always /p:AppxBundlePlatforms="x86|x64" /p:Configuration=Debug

But I will get errors for my test projects, like:

MakeAppx : error : Error info: error 80080204: The package with file name "Tests.XXXX.Shared.Uwp_1.0.0.0_x86_Debug.appx" and package full name "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx_1.0.0.0_x86__xxxxxxxxxxx" is not valid in the bundle because it has a different package family name than other packages in the bundle. The expected package name is xxxx-Test.xxxxTestApp....

My guess is that I should not use "Always" for AppxBundle, but I cannot find any document online mentioning how to set this value as "If Needed". I also tried to add "Never" in project properties for the test project, but the command line argument seems to overwrite that.

So my question is: How to exclude a test project from the solution when creating a bundle using msbuild in the command line?

laishiekai
  • 841
  • 1
  • 13
  • 26

1 Answers1

1

How to exclude a test project from the solution when creating a bundle using msbuild in the command line?

To resolve this issue, you can build the project file directly when you create a bundle using MSBuild in the command line:

msbuild .\YourProjectFile.csproj /p:AppxBundle=Always /p:AppxBundlePlatforms="x86|x64" /p:Configuration=Debug

Alternatively, you can open test project file and add the following properties at the end of the first <PropertyGroup> element to exclude the test project to be included:

 <PropertyGroup>
    <AppxBundle>Never</AppxBundle>
 </PropertyGroup>

Check this thread and the document for some more details.

Hope this helps.

Community
  • 1
  • 1
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Thanks for the answer. After I add the property, msbuild will be able to finish but it only generate a bundle for x64 without x86. How do I fix this? When I use the wizard it can generate the bundle with both platforms. – laishiekai Nov 06 '18 at 17:14
  • Also, does this command actually build x86 and x64 first, and bundle them? I found that if I clean both and then run the command above, I will get errors about "Could not find a recipe file for the referenced UWP application" – laishiekai Nov 06 '18 at 18:27
  • @laishiekai, It works fine on mt side, I can get the bundle file `App1_1.0.0.0_x86_x64_Debug.appxbundle`. Makre sure the parameter is `/p:AppxBundlePlatforms="x86|x64"` Both have x86 and x64 and is your system x86? It seems the x86 OS could not generate the x64 bundle. – Leo Liu Nov 07 '18 at 07:47
  • Thanks for the response. I figured out my issue and posted an answer here: https://stackoverflow.com/questions/51892208/uwp-with-desktop-bridge-package-build-automation-with-msbuild/53181888#53181888 – laishiekai Nov 07 '18 at 18:47