Reputation: 137
MyApp.csproj
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
<TargetFrameworks>net48;net5.0-windows</TargetFrameworks>
<Configurations>Release</Configurations>
<Platforms>AnyCPU;x64;x86</Platforms>
<RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
<SelfContained>false</SelfContained>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' And '$(TargetFramework)'=='net5.0-windows' And '$(RuntimeIdentifier)'=='win-x64'">
<OutputPath>..\..\app\</OutputPath>
<AssemblyName>my-app</AssemblyName>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86' And '$(TargetFramework)'=='net5.0-windows' And '$(RuntimeIdentifier)'=='win-x86'">
<OutputPath>..\..\x86\app\</OutputPath>
<AssemblyName>my-app</AssemblyName>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
</Project>
these commands build both x64 and x86 assemblies in "....\app" and "....\x86\app" folders
msbuild.exe "MyApp.csproj" /t:restore;rebuild /p:RuntimeIdentifier=win-x64
msbuild.exe "MyApp.csproj" /t:restore;rebuild /p:RuntimeIdentifier=win-x86
but clicking Build (Ctrl+F5) or Debug (F5) in Visual Studio outputs to "bin\Release\net5.0-windows" directory.
how to force Build (Ctrl+F5) and Debug (F5) to do the same as this command:
msbuild.exe "MyApp.csproj" /t:restore;rebuild /p:RuntimeIdentifier=win-x64
Upvotes: 0
Views: 539
Reputation: 2337
Here is my code:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net5.0-windows;net472</TargetFrameworks>
<Nullable>disable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<Configurations>Release</Configurations>
<Platforms>AnyCPU;x64;x86</Platforms>
<SelfContained>false</SelfContained>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutputPath>..\..\app\</OutputPath>
<AssemblyName>my-app</AssemblyName>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<OutputPath>..\..\x86\app\</OutputPath>
<AssemblyName>my-app</AssemblyName>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
</Project>
You can refer to the following steps to solve this problem:
1.Select target framework .net5.0-windows
2.Choose Platform x86
3.Debug your project with the button or F5
4.Change Platform x64 and Debug it.
5.Finally we can get these folders.
Upvotes: 1