Reference multitarget class library in VS2017 solution
up vote
1
down vote
favorite
In VisualStudio 2017 I created a class library which targets .net 4.0 (to support legacy applications on win XP) and 4.6.1 framework. I did this by making use of the new .csproj format which allows to specify multiple target frameworks as shown below.
<PropertyGroup>
<TargetFrameworks>net40;net472</TargetFrameworks>
</PropertyGroup>
Building the library for both frameworks works perfectly. I get my two folders, net40 and net472 which contain both a dll for the specific target framework.
In my solution, I now have two further projects. One WinForms App that references my library and a WPF App which also references it. WinForms App should use net40 and WPF App net472 version of my library.
When I add a project reference to the library in my WinForms App it uses net40 version. Everything fine.
But when I reference the class library project to my WPF application (which builds for net472) it also uses the net40 dll. But I want my WPF app to use the net472 version of the library.
Is there any possibility to select the target framework when referencing a multitarget class library as project reference in VS2017?
Update:
When I build a multitarget nuget package from the library and use the package to reference it, everything is fine. WPF app uses net472 and WinForms net40 automatically.
c# visual-studio-2017 class-library multitargeting
add a comment |
up vote
1
down vote
favorite
In VisualStudio 2017 I created a class library which targets .net 4.0 (to support legacy applications on win XP) and 4.6.1 framework. I did this by making use of the new .csproj format which allows to specify multiple target frameworks as shown below.
<PropertyGroup>
<TargetFrameworks>net40;net472</TargetFrameworks>
</PropertyGroup>
Building the library for both frameworks works perfectly. I get my two folders, net40 and net472 which contain both a dll for the specific target framework.
In my solution, I now have two further projects. One WinForms App that references my library and a WPF App which also references it. WinForms App should use net40 and WPF App net472 version of my library.
When I add a project reference to the library in my WinForms App it uses net40 version. Everything fine.
But when I reference the class library project to my WPF application (which builds for net472) it also uses the net40 dll. But I want my WPF app to use the net472 version of the library.
Is there any possibility to select the target framework when referencing a multitarget class library as project reference in VS2017?
Update:
When I build a multitarget nuget package from the library and use the package to reference it, everything is fine. WPF app uses net472 and WinForms net40 automatically.
c# visual-studio-2017 class-library multitargeting
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In VisualStudio 2017 I created a class library which targets .net 4.0 (to support legacy applications on win XP) and 4.6.1 framework. I did this by making use of the new .csproj format which allows to specify multiple target frameworks as shown below.
<PropertyGroup>
<TargetFrameworks>net40;net472</TargetFrameworks>
</PropertyGroup>
Building the library for both frameworks works perfectly. I get my two folders, net40 and net472 which contain both a dll for the specific target framework.
In my solution, I now have two further projects. One WinForms App that references my library and a WPF App which also references it. WinForms App should use net40 and WPF App net472 version of my library.
When I add a project reference to the library in my WinForms App it uses net40 version. Everything fine.
But when I reference the class library project to my WPF application (which builds for net472) it also uses the net40 dll. But I want my WPF app to use the net472 version of the library.
Is there any possibility to select the target framework when referencing a multitarget class library as project reference in VS2017?
Update:
When I build a multitarget nuget package from the library and use the package to reference it, everything is fine. WPF app uses net472 and WinForms net40 automatically.
c# visual-studio-2017 class-library multitargeting
In VisualStudio 2017 I created a class library which targets .net 4.0 (to support legacy applications on win XP) and 4.6.1 framework. I did this by making use of the new .csproj format which allows to specify multiple target frameworks as shown below.
<PropertyGroup>
<TargetFrameworks>net40;net472</TargetFrameworks>
</PropertyGroup>
Building the library for both frameworks works perfectly. I get my two folders, net40 and net472 which contain both a dll for the specific target framework.
In my solution, I now have two further projects. One WinForms App that references my library and a WPF App which also references it. WinForms App should use net40 and WPF App net472 version of my library.
When I add a project reference to the library in my WinForms App it uses net40 version. Everything fine.
But when I reference the class library project to my WPF application (which builds for net472) it also uses the net40 dll. But I want my WPF app to use the net472 version of the library.
Is there any possibility to select the target framework when referencing a multitarget class library as project reference in VS2017?
Update:
When I build a multitarget nuget package from the library and use the package to reference it, everything is fine. WPF app uses net472 and WinForms net40 automatically.
c# visual-studio-2017 class-library multitargeting
c# visual-studio-2017 class-library multitargeting
edited Nov 22 at 15:09
asked Nov 21 at 21:46
Quergo
370213
370213
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420916%2freference-multitarget-class-library-in-vs2017-solution%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown