0

I need to do multi targeting for one of the sample application that I was working on. Here is the structure.

I have an AppOne(Console App) and two class libraries(CLSOne, CLSTwo). AppOne calls CLSOne. CLSOne call CLSTwo. CLSTwo has logic that interacts with azure to fetch secret from Key vault. CLSTwo has dependencies to Microsoft.Azure.KeyVault & Microsoft.Azure.Services.AppAuthentication.

All of the above is in DotNet Framework. Now I want to multitarget this application to DotNet Standard 2.0 without changing the csproj format.

Can someone help me out how can I achieve this?

user2083386
  • 135
  • 3
  • 19
  • 1
    Just switch to the SDK-style csproj format: it's superior to the old format, and it's worth doing even if you're just targetting .NET Framework. It doesn't take long and you'll appreciate the benefits. You'll get multi-targetting as an additional bonus! Nobody should be using the old csproj format at this point in time (with occasional exceptions, like WPF targetting .NET Framework if you don't want to use MSBuild.Sdk.Extras) – canton7 Feb 11 '21 at 17:15
  • How can I switch to SDK-style csproj format? In my scenario, I need to multitarget the CLSTwo class library. – user2083386 Feb 11 '21 at 17:32
  • There are plenty of articles and even some tools describing different approaches to migrating your csproj files, back from the days when SDK-style csprojs were introduced. Your question says you want to multitarget the application, in which case CLSOne and CLSTwo will need to be multi-targeted (unless you can pick a .NET Standard version which is supported by the .NET Framework version you target, in which case just use that. [See this table](https://learn.microsoft.com/en-us/dotnet/standard/net-standard). If you do just want to multi-target CLSTwo, then just do that. – canton7 Feb 11 '21 at 17:38
  • Just add another project file. You don't need to add each file to it as it recognizes them automatically. Then build 2 projects in one solution. Both will compile same CS files – T.S. Feb 11 '21 at 22:41
  • What type of another project? sdk project? Actually I want to target my current project i.e. CLSTwo to net472 and netstandard2.0. I tried this, but it started giving errors for the references that I was using which are related to the azure key vault. I need to do the project conversion without creating any additional projects. – user2083386 Feb 11 '21 at 23:59
  • "*but it started giving errors for the references that I was using which are related to the azure key vault*" -- we can't help without seeing the errors I'm afraid – canton7 Feb 12 '21 at 09:10

0 Answers0