-
This project can run normally in Debug or Release mode, but it cannot be opened in the exe after publish. I have tried to publish other unpackaged projects, and all of them were successfully run after publish. Only my project cannot be opened normally after release. Here's my project's csproj code: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>SpaceEngineersBlueprintEditor</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) < 8">win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<Nullable>enable</Nullable>
<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<WindowsSdkPackageVersion>10.0.22621.38</WindowsSdkPackageVersion>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Page Remove="Styles\Thickness.xaml" />
</ItemGroup>
<ItemGroup>
<Content Include="Styles\Thickness.xaml">
<Generator>MSBuild:Compile</Generator>
</Content>
</ItemGroup>
<ItemGroup>
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
<!--
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
Tools extension to be activated for this project even if the Windows App SDK Nuget
package has not yet been restored.
-->
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.2.241112-preview1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
<PackageReference Include="XFEExtension.NetCore" Version="3.2.0" />
<PackageReference Include="XFEExtension.NetCore.AutoConfig" Version="1.3.0" />
<PackageReference Include="XFEExtension.NetCore.AutoPath" Version="1.0.1" />
<PackageReference Include="XFEExtension.NetCore.TodoHighLight" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Page Update="Views\BlueprintEditPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Using Include="Microsoft.UI.Xaml" />
<Using Include="Microsoft.UI.Xaml.Controls" />
<Using Include="SpaceEngineersBlueprintEditor.Profiles.CacheProfiles" />
<Using Include="SpaceEngineersBlueprintEditor.Profiles.CrossVersionProfiles" />
<Using Include="SpaceEngineersBlueprintEditor.Utilities.Helpers" />
</ItemGroup>
<ItemGroup>
<Page Update="Views\SettingPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\AppShellPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\BlueprintsViewPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Folder Include="Profiles\CurrentVersionProfiles\" />
<Folder Include="Profiles\SynProfiles\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SpaceEngineersBlueprintEditor.SpaceEngineersCore\SpaceEngineersBlueprintEditor.SpaceEngineersCore.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="EmptyKeys.UserInterface">
<HintPath>..\DLLReference\EmptyKeys.UserInterface.dll</HintPath>
</Reference>
<Reference Include="EmptyKeys.UserInterface.Core">
<HintPath>..\DLLReference\EmptyKeys.UserInterface.Core.dll</HintPath>
</Reference>
<Reference Include="HavokWrapper">
<HintPath>..\DLLReference\HavokWrapper.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\DLLReference\log4net.dll</HintPath>
</Reference>
<Reference Include="ProtoBuf.Net">
<HintPath>..\DLLReference\ProtoBuf.Net.dll</HintPath>
</Reference>
<Reference Include="ProtoBuf.Net.Core">
<HintPath>..\DLLReference\ProtoBuf.Net.Core.dll</HintPath>
</Reference>
<Reference Include="Sandbox.Common">
<HintPath>..\DLLReference\Sandbox.Common.dll</HintPath>
</Reference>
<Reference Include="Sandbox.Game">
<HintPath>..\DLLReference\Sandbox.Game.dll</HintPath>
</Reference>
<Reference Include="Sandbox.Game.XmlSerializers">
<HintPath>..\DLLReference\Sandbox.Game.XmlSerializers.dll</HintPath>
</Reference>
<Reference Include="Sandbox.Graphics">
<HintPath>..\DLLReference\Sandbox.Graphics.dll</HintPath>
</Reference>
<Reference Include="Sandbox.RenderDirect">
<HintPath>..\DLLReference\Sandbox.RenderDirect.dll</HintPath>
</Reference>
<Reference Include="SpaceEngineers.Game">
<HintPath>..\DLLReference\SpaceEngineers.Game.dll</HintPath>
</Reference>
<Reference Include="SpaceEngineers.ObjectBuilders">
<HintPath>..\DLLReference\SpaceEngineers.ObjectBuilders.dll</HintPath>
</Reference>
<Reference Include="SpaceEngineers.ObjectBuilders.XmlSerializers">
<HintPath>..\DLLReference\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
</Reference>
<Reference Include="Steamworks.NET">
<HintPath>..\DLLReference\Steamworks.NET.dll</HintPath>
</Reference>
<Reference Include="VRage">
<HintPath>..\DLLReference\VRage.dll</HintPath>
</Reference>
<Reference Include="VRage.Ansel">
<HintPath>..\DLLReference\VRage.Ansel.dll</HintPath>
</Reference>
<Reference Include="VRage.Audio">
<HintPath>..\DLLReference\VRage.Audio.dll</HintPath>
</Reference>
<Reference Include="VRage.Game">
<HintPath>..\DLLReference\VRage.Game.dll</HintPath>
</Reference>
<Reference Include="VRage.Game.XmlSerializers">
<HintPath>..\DLLReference\VRage.Game.XmlSerializers.dll</HintPath>
</Reference>
<Reference Include="VRage.Input">
<HintPath>..\DLLReference\VRage.Input.dll</HintPath>
</Reference>
<Reference Include="VRage.Library">
<HintPath>..\DLLReference\VRage.Library.dll</HintPath>
</Reference>
<Reference Include="VRage.Math">
<HintPath>..\DLLReference\VRage.Math.dll</HintPath>
</Reference>
<Reference Include="VRage.Math.XmlSerializers">
<HintPath>..\DLLReference\VRage.Math.XmlSerializers.dll</HintPath>
</Reference>
<Reference Include="VRage.NativeWrapper">
<HintPath>..\DLLReference\VRage.NativeWrapper.dll</HintPath>
</Reference>
<Reference Include="VRage.Network">
<HintPath>..\DLLReference\VRage.Network.dll</HintPath>
</Reference>
<Reference Include="VRage.Render">
<HintPath>..\DLLReference\VRage.Render.dll</HintPath>
</Reference>
<Reference Include="VRage.Render11">
<HintPath>..\DLLReference\VRage.Render11.dll</HintPath>
</Reference>
<Reference Include="VRage.Scripting">
<HintPath>..\DLLReference\VRage.Scripting.dll</HintPath>
</Reference>
<Reference Include="VRage.Steam">
<HintPath>..\DLLReference\VRage.Steam.dll</HintPath>
</Reference>
<Reference Include="VRage.XmlSerializers">
<HintPath>..\DLLReference\VRage.XmlSerializers.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Page Update="Views\BlueprintDetailPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Views\MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Explorer "Package and Publish" context menu entry to be enabled for this project even if
the Windows App SDK Nuget package has not yet been restored.
-->
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>
<!-- Publish Properties -->
<PropertyGroup>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
</PropertyGroup>
</Project> Here's my project git link: https://github.com/XFEstudio/SpaceEngineersBlueprintEditorInWinUI |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
i think this is because of PublishTrim
|
Beta Was this translation helpful? Give feedback.
-
I have solved this problem, this problem is due to the wrong csproj file setting, you need to delete the: <RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) < 8">win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<WindowsSdkPackageVersion>10.0.22621.38</WindowsSdkPackageVersion>
<PublishProfile>win-$(Platform).pubxml</PublishProfile> And add <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers> The final csproj may looks like this: <PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>SpaceEngineersBlueprintEditor</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<Nullable>enable</Nullable>
<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> Then create new publish profile, and delete all of the bin and obj folder in every project in your solution, open your visual studio, and start publish, it will run normally |
Beta Was this translation helpful? Give feedback.
I have solved this problem, this problem is due to the wrong csproj file setting, you need to delete the:
And add
The final csproj may looks like this: