Visual Studio 2022 specify runtime identifier during build and debug using WSL2 debug toolbar button

gitzko 0 Reputation points
2023-03-08T07:38:41.54+00:00

Hi,

I have a project that I'd like to keep buildable for Linux and Windows for the time being. The problem is it relies on IBM DB2 library which has a separate nuget for Linux and Windows. I have found a way to use RuntimeIdentifiers property in csproj file, and that with dotnet build -r switch allows me to specify which runtime to target during build, but I haven't yet found a way to specify the runtime during build triggered by WSL2 debug button on Visual Studio 2022 toolbar.

Any way to specify runtimeIdentifier without cmd line?

<PropertyGroup>
    <RuntimeIdentifiers>win10-x64;linux-x64</RuntimeIdentifiers>
  </PropertyGroup>
  <Choose>
    <When Condition="$(RuntimeIdentifier) != ''">
      <ItemGroup>
        <PackageReference Include="Net.IBM.Data.Db2-lnx" Version="6.0.0.300" Condition="$(RuntimeIdentifier.StartsWith('linux-x64'))"/>
        <PackageReference Include="Net.IBM.Data.Db2" Version="6.0.0.300" Condition="$(RuntimeIdentifier.StartsWith('win-x64'))"/>
      </ItemGroup>
    </When>
    <Otherwise>
      <ItemGroup>
        <PackageReference Include="Net.IBM.Data.Db2-lnx" Version="6.0.0.300" Condition="$([MSBuild]::IsOsPlatform('Linux'))"/>
        <PackageReference Include="Net.IBM.Data.Db2" Version="6.0.0.300" Condition="$([MSBuild]::IsOSPlatform('Windows'))"/>
      </ItemGroup>
    </Otherwise>
  </Choose>
Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2023-03-08T11:22:19.6066667+00:00

    Hi @gitzko

    Welcome to Microsoft Q&A! 

    You can right click on your project in Solution Explorer > Publish > Target runtime to specify the runtime.

    User's image

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.