Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

.net - change multi-target project output path and file name

I have a project in D:devapp with this configuration:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

    <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFrameworks>net48;net5.0-windows</TargetFrameworks>
        <UseWindowsForms>true</UseWindowsForms>
    </PropertyGroup>
    
</Project>

what should I add to force VS to generate the exe files as follow:

D:inapp-net48.exe for the net48 target framework

D:inapp-net50.exe for the net5.0-windows target framework

question from:https://stackoverflow.com/questions/65599082/change-multi-target-project-output-path-and-file-name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Add a couple of directives

<PropertyGroup Condition="'$(TargetFramework)'=='net48'">
    <AssemblyName>app-net48</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net5.0-windows'">
    <AssemblyName>app-net50</AssemblyName>
</PropertyGroup>

surely, you can also use

<Choose>
   <When Condition="....">
      <PropertyGroup>
      </PropertyGroup>
   </When>
   <When Condition="....">
      <PropertyGroup>
      </PropertyGroup>
   </When>
</Choose>

Reference link

use <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> in the initial <PropertyGroup> to remove adding folder structures to the output


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...