Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: can reference Win8.1 project from Net4.5 test project?

My Windows app consists of 4 projects targeting Windows 8.1 and several testing projects:

Screenshot of solution projects

The "...App.Core" project was previously a Windows 8 project, which also targeted the .Net 4.5 framework. But because of this, there was some async features that couldn't be used.

We now need full async ability and the project has been re-targeted for only Windows8.1.

However, doing that broke the "...App.Core.Tests" project, which is a .Net 4.5 test project. It was referencing the App.Core project, and the reference is now broken.

Question: Is there a way to target the Windows 8.1 project from the Test project (without having to create a new test project)? The test project has a considerable number of tests, folders, and nuget package references that would be a major pain to have to transfer to a new project.

If I try to add the reference now, I get the annoyingly terse "Unable to add a reference to project 'MyProject.App.Core'."

Also, retargeting the App.Core project means updating the targets of the other 8.1 projects and reinstalling every nuget package for every project. Which is why I would rather solve this another way.. if there is one.

Is there some limitation of a .Net 4.5 project being able to reference a Windows 8.1 project? Or maybe I'm just doing something incorrectly.

Update

Based on the comment below from @PiLHA, I added .NET 4.5.1 as a target. It changed the library type from "Windows 8.1" to "Portable", but it broke all the async calls.

reference change

Note: I have Microsoft.Bcl v1.1.10, Microsoft.Bcl.Async v1.0.68, and Microsoft.Bcl.Build v1.0.21 added as nuget packages to the "MyProject.App.Core" project.

like image 724
jwatts1980 Avatar asked May 17 '17 15:05

jwatts1980


2 Answers

Try this: Right click on your solution file in Solution Explorer window, click Add and then select Existing Project.

enter image description here

Once the project is a part of the solution, you will be able to add project reference.

like image 159
lax1089 Avatar answered Oct 20 '22 00:10

lax1089


Take a look at the project file itself and see if there is something odd in the references group. Following link Cannot Edit or Add Path to Reference File in Visual Studio 2010 discusses manually editing a project file. I usually just open up the project file in a text editor. Look for ItemGroup, and the project's references will be included in that group. You can also try to manually add the reference this way.

like image 44
stewelement Avatar answered Oct 19 '22 23:10

stewelement