gpt4 book ai didi

wpf - 使用 MSIX 发布 WPF Core...多个问题

转载 作者:行者123 更新时间:2023-12-03 20:53:40 41 4
gpt4 key购买 nike

编辑 #1 开始

要复制这个:

  • 创建一个新的“vanilla”WPF 应用程序来解决 .Net Core 3.1
  • 添加 Windows Application Packaging Project到解决方案(按照 Set up your desktop application for MSIX packaging in Visual Studio 中提到的步骤)
  • 尝试“部署”到 UNC 路径...

  • 编辑 #1 结束

    我正在将 WPF .net 框架应用程序转换为 .net core 3.1。此应用程序是一个“内部”工具,我们一直使用 ClickOnce 将其部署在共享的 UNC 路径上。很简单....

    我现在已经在 .Net Core 中重新编写了它并需要部署它。发现“ClickOnce”不再可用,我明白我必须走“MSIX”路线。文档看起来应该很简单,但我想我错过了一些东西......

    1 - 我不得不将我的开发人员设置从“侧栏”更改为“开发人员模式”
    2 - 它在我的机器上构建良好,但在 Azure DevOps 上失败
    3 - 我如何实际部署它......?

    让我们依次来看看。

    1 - 侧边栏 => 开发者模式问题

    我将一个新的 Windows 应用程序打包项目添加到我的解决方案中,为目标版本和最低版本选择 Windows 版本 1909,并将我的 WPF 应用程序设置为入口点。我尝试运行它,它迫使我从“侧栏”更改为“开发人员模式”。

    这是否只影响我作为开发人员....如果是这样,那很好。我怀疑最终的最终用户会想要这样做。

    2 - Azure DevOps 构建管道失败

    在本地,它编译得很好,即使在我将所有警告设置为错误并运行 FxCop 的 Release模式下也是如此。将其推送到 Azure,它说:

    [error]C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(234,5): Error NETSDK1047: Assets file 'd:\a\1\s\MyApp\MyApp\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v3.1/win-x86'.
    Ensure that restore has run and that you have included 'netcoreapp3.1' in the TargetFrameworks for your project.
    You may also need to include 'win-x86' in your project's RuntimeIdentifiers.



    好的
  • 我的 YAML 文件在构建之前有一个“还原 NuGet 包”步骤
    成功了。
  • 我查看我的应用程序的 SKD 项目文件,然后
    我看到<TargetFramework>netcoreapp3.1</TargetFramework>
  • 关于“RuntimeIdentifiers”,我找到了链接 Additions to the csproj format for .NET Core如此添加 <RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>紧接着 <TargetFramework>netcoreapp3.1</TargetFramework> (我应该更具体地使用 win10-x64;win10-x86 吗?)

  • 无论哪种方式,这都失败了,消息略有不同:

    There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "path to my dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.



    3 - 我如何实际部署它?

    来自 MSIX: The Modern Way to Deploy Desktop Apps on Windows它指出:

    To generate the actual MSIX package, there’s a wizard available under Project | Store | Create App Packages in Visual Studio.



    我的机器上没有……我什至安装了 Visual Studio 工作负载“通用 Windows 平台开发”。我可以在“构建”菜单下看到“部署”...但这是它....我将 UNC 路径放在哪里?

    我想我错过了一些相当基本的东西......

    我的 CSPROJ 的相关部分是
      <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
    <UseWPF>true</UseWPF>
    </PropertyGroup>

    打包项目是:
    <?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>08b169a2-6461-440b-afa1-ca35c7d98aa7</ProjectGuid>
    <TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
    <TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
    <DefaultLanguage>en-US</DefaultLanguage>
    <AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
    <EntryPointProjectUniqueName>..\MyApp\MyApp.csproj</EntryPointProjectUniqueName>
    <PackageCertificateThumbprint>01C08F1E21D5624A484DB362BE4F056504B825CC</PackageCertificateThumbprint>
    </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>
    <ItemGroup>
    <ProjectReference Include="..\MyApp\MyApp.csproj">
    <SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
    </ProjectReference>
    </ItemGroup>
    <Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
    </Project>

    (我可以/应该删除对我认为不相关的“DEBUG”和“ARM”的引用吗??)

    list 是
    <?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="46aebba6-d403-4412-89c0-05279b36e54e"
    Publisher="CN=MyCompany"
    Version="2020.5.0.0" />

    <Properties>
    <DisplayName>MyApp</DisplayName>
    <PublisherDisplayName>MyCompany</PublisherDisplayName>
    <Logo>Images\StoreLogo.png</Logo>
    </Properties>

    <Dependencies>
    <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="MyApp.Package"
    Description="MyApp.Package"
    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>

    谢谢!

    最佳答案

    在 .waproj 项目文件中请添加,

    <PropertyGroup>
    <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
    None
    </ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
    </PropertyGroup>

    关于wpf - 使用 MSIX 发布 WPF Core...多个问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61826678/

    41 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com