microsoft / msix-packaging

MSIX SDK
MIT License
978 stars 165 forks source link

[BUG] Cant build msix package for my app with custom App wpf #511

Closed jmecosta closed 7 months ago

jmecosta commented 2 years ago

Hi

We have a sdk type of library that provides custom base for our wpf apps... Then each exe inherits from Fusion.App instead of System.Windows.Application

MSIX is not able to figure out the entry point for this scenario.

exe:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFrameworks>net6-windows</TargetFrameworks>
    <UseWPF>true</UseWPF>
    <OutputPath>$(BINDir)</OutputPath>
    <ApplicationIcon>structures.ico</ApplicationIcon>
    <Platforms>x64</Platforms>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="CommandLineParser" Version="2.3.0" />
    <PackageReference Include="DotNetZip" Version="1.16.0" />
    <PackageReference Include="System.Text.Json" Version="6.0.3" />
    <PackageReference Include="Tekla.Account.Identity" Version="2.0.13809" />
  </ItemGroup>
</Project>

wapproj

<?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>
  <PropertyGroup>
    <WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
  </PropertyGroup>
  <Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
  <PropertyGroup>
    <ProjectGuid>6f560416-7a9b-4a78-a268-e16e563754b6</ProjectGuid>
    <TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
    <DefaultLanguage>en-US</DefaultLanguage>
    <AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
    <NoWarn>$(NoWarn);NU1702</NoWarn>
    <EntryPointProjectUniqueName>..\SupportTool\SupportTool.csproj</EntryPointProjectUniqueName>
  </PropertyGroup>
  <ItemGroup>
    <AppxManifest Include="Package.appxmanifest">
      <SubType>Designer</SubType>
    </AppxManifest>
  </ItemGroup>
  <ItemGroup>
    <Content Include="Images\SplashScreen.scale-200.png" />
    <Content Include="Images\LockScreenLogo.scale-200.png" />
    <Content Include="Images\Square150x150Logo.scale-200.png" />
    <Content Include="Images\Square44x44Logo.scale-200.png" />
    <Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
    <Content Include="Images\StoreLogo.png" />
    <Content Include="Images\Wide310x150Logo.scale-200.png" />
  </ItemGroup>
  <Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" PrivateAssets="all" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\SupportTool\SupportTool.csproj" />
  </ItemGroup>
</Project>

appxmanifest:

<?xml version="1.0" encoding="utf-8"?>

<Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
  IgnorableNamespaces="uap rescap">

  <Identity
    Name="3bdc9abc-1d9b-4680-a78b-c9ba05b13be9"
    Publisher="CN=xxx"
    Version="1.0.0.0" />

  <Properties>
    <DisplayName>WapProjTemplate1</DisplayName>
    <PublisherDisplayName>xxx</PublisherDisplayName>
    <Logo>Images\StoreLogo.png</Logo>
  </Properties>

  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
  </Dependencies>

  <Resources>
    <Resource Language="x-generate"/>
  </Resources>

  <Applications>
    <Application Id="App"
      Executable="$targetnametoken$.exe"
      EntryPoint="$targetentrypoint$">
      <uap:VisualElements
        DisplayName="WapProjTemplate1"
        Description="WapProjTemplate1"
        BackgroundColor="transparent"
        Square150x150Logo="Images\Square150x150Logo.png"
        Square44x44Logo="Images\Square44x44Logo.png">
        <uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
        <uap:SplashScreen Image="Images\SplashScreen.png" />
      </uap:VisualElements>
    </Application>
  </Applications>

  <Capabilities>
    <Capability Name="internetClient" />
    <rescap:Capability Name="runFullTrust" />
  </Capabilities>
</Package>

Results in: 2>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\DesktopBridge\Microsoft.DesktopBridge.targets(744,5): error : Specified EntryPointExe '' was not found in the project outputs.

Creating a basic wpf net6-windows with the same basic wap project works...

My guess is that my app entry point is not the default you would find in a wpf app. we have our custom framework that kickoff the app: Like this image

So the all msix is confused and doesnt really know where the entry point is...

How to package this kind of tool?

tried also, speficiing directly the exe and entry point that ILSpy provides but same error <Application Id="App" Executable="SupportTool/SupportTool.exe" EntryPoint="SupportTool.SupportToolApp.Main">

Thanks in advance

Regards

Jorge Costa

sbanni commented 2 years ago

Hello, the packaging project does not support the property 'TargetFrameworks' found on your dotnet project. The packaging project needs to build for a specific framework, so specifying the property 'TargetFramework' should fix the error you are seeing.

jmecosta commented 2 years ago

Alright thanks for the clarification. Maybe improving the error message would help... I would never concluded this based on the entry point 😀

On Wed, May 4, 2022, 01:56 scoban @.***> wrote:

Hello, the packaging project does not support the property 'TargetFrameworks' found on your dotnet project. The packaging project needs to build for a specific framework, so specifying the property 'TargetFramework' should fix the error you are seeing.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/msix-packaging/issues/511#issuecomment-1116735595, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH6HSCXQAIFP37W6U4DWCTVIGVI5ANCNFSM5UPDQJCA . You are receiving this because you authored the thread.Message ID: @.***>

jmecosta commented 2 years ago

@sbanni do u want to keep this open to improve the error message? otherwise you can closed this.