I have one PCL project, in this project I made Xunit project, which I want to reference my PCL project to test it.
When I'm trying to add a reference, I cant check it, because of I have an error like this:
Incompatible target framework: .NETPortable,Version=v.4.5,profile=Profile111)
I'm using Visual studio Mac, I've also updated everything from Check Updates
Also updated all Nuget packages.
I am assuming this is a .NET Core xUnit project which is trying to reference the PCL project.
Currently this is prevented in Visual Studio for Mac 7.2 and earlier versions. In Visual Studio for Mac 7.3 and later, currently available on the alpha channel, it is possible to reference a PCL project from a .NET Core project.
For Visual Studio for Mac 7.2 the only workaround would be to add the project reference manually by editing the .csproj in the text editor. For example:
<ItemGroup>
<ProjectReference Include="..\PclProject\PclProject.csproj" />
</ItemGroup>
Related
I need your help. I'm working in a .net5 project and I created a xUnit project but I created with .net6 and it is conflicting.
I tryied to change target frameworking in file .csproj but I beliave that it more things.
Thanks very much.
To change the .net version of your project, right click on your xUnit project, and go to Properties. After that,change the Target Framework version
I created a simple library .NET Framework project.
I would like to generate NuGet packages after build as described here.
However, the Package tab is missing, here is a screenshot:
Visual Studio 2017 package tab is missing in project settings
That because your project is library .NET Framework, which still using packages.config to manage NuGet packages. And Package tab is only supported by the new nuget package management form: PackageReference.
.NET Standard class library or .NET Core projects come with PackageReference enabled by default. So you can create .NET Standard class library or .NET Core project, then you will see Package tab on the properties window.
If you want to use the Package tab for library .NET Framework project, you can convert your project from the old .csproj to new .csproj, (Right click your project->Unload project->Edit .csproj. Replace the contents of your csproj with the following:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>
</Project>
See Old csproj to new csproj: Visual Studio 2017 upgrade guide for more info about convert old .csproj to new .csproj.
Note: Need to delete the AssemblyInfo.cs file in the Properties.
After convert to new .csproj, you will get the Package tab for library .NET Framework project:
Hope this helps.
When trying to install the netmq vis nuget, I get the following error:
Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
but the package does not contain any assembly references or content files that
are compatible with that framework. For more information, contact the package author.
The problem is that netmq depends on AsyncIO. when installing it, nuget find that the assembly is not compatible with .Net 4.5.
so nuget fail in installing AsyncIO, and then failed in installing netmq.
So I downloaded the AsyncIO Source from Github and build it locally with .Net 4.5.
After that and added the dll of AsyncIO built locally as a reference for my project.
Theoretically, NetMQ should be successfully installed with nuget. because I added the needed reference to AsyncIO.
But when trying to reinstall NetMQ, I get the same error:
Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
but the package does not contain any assembly references or content files that
are compatible with that framework. For more information, contact the package author.
and nuget did not detect that I added 'AsyncIO 0.1.18' in my project.
How to let nuget detect that I added this reference in my project?
Have a look here:
.NET Portable profiles
Profile111 is a combination of:
.NET Framework 4.5
Windows 8.0
Windows Phone 8.1
or in other words:
portable-net45+netcore45+wpa81
So your project into which you are trying to append the NuGet targets Windows Phone 8.1 and other 2 platforms, I mention this one as the most restrictive.
Now let's have a look at the named NuGet package's source:
<ProjectGuid>{3830B7A3-0225-4FDA-B155-E085E183650C}</ProjectGuid>
<OutputType>Library</OutputType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
What do we have here? We can see that the project is not a PCL. It is targeting full .NET 4.0 framework which is not available on Windows Phone 8.1. And your library does target Windows Phone 8.1. See the problem?
You say that if you compile the AsyncIO targeting .NET 4.5 than you can successfully append it into your project as a reference? That's not altogether true. I mean you can append a reference to it but you cannot use it. You will see that when you try to call something from that reference.
In order to use AsyncIO from you PCL will have to build AsyncIO as a PCL targeting the same or more restrictive set of platforms. Try creating a PCL project targeting Profile111 and try compiling the AsyncIO code with it (just link the original AsyncIO source files (*.cs) into this new AsyncIO_PCL project). If you are lucky enough and the code of AsyncIO is really compatible you will be able to use that library.
Here are your steps:
Create a new project (named AsyncIO_PCL) of type PCL class library.
Pick the Profile111 platform set i.e.
.NET Framework 4.5
Windows 8.0
Windows Phone 8.1
Link all the .cs files from the original AsyncIO project save one (AssemblyInfo.cs) into the new AsyncIO_PCL project.
Set the output assembly name to the same as in original AsyncIO project.
Try building the project.
Your ability to build the AsyncIO as a PCL with the required set of supported platforms depends on AsyncIO code i.e. which API is used inside and if that API is supported by all the three platforms you are targeting.
Try clicking right-button on the project -> Properties. In the "Application" menu check the "Target Framework". It should be set to .NET Framework 4.5
I'm using one of those new "Class Library (NuGet Package)" templates from Visual Studio, and I want to create an xUnit test library for it.
The problem is, when I create a new .csproj library and try to reference the .xproj package, Visual Studio says "The reference to XXXX could not be resolved."
Why is this happening and what can I do to fix this?
You can use the SideWaffle template pack VS extension to create xUnit project templates using the new xproj project type. It is developed by a Microsoft developer and is the recommended approach at the moment (It is what they use in ASP.NET 5).
I have a Visual Studio 2008 project that is a Smart Device project targeting a .NET 3.5 Compact Framework Windows CE device and it currently references a 3.5 class library project.
What I would like to do is be able to add the class library into a Visual Studio 2012/2013 solution without "migrating" it.
For example the structure is currently:
VS2008 Solution
Smart Device Project
Class Library Project
I want to have is:
A VS2008 Solution
Smart Device Project
Class Library Project
A VS2013 Solution
Class Library Project
ASP.NET MVC Project
The result of this would be that I can work on the Smart device project in VS2008 and add classes to the Class Library Project, and then be able to open the VS2013 solution file and have those new classes available.
When I look at the difference between a 2008 Class Project and a 2013 Class Project csproj files, the only thing that really is different is the ToolsVersion on the Project element (http://msdn.microsoft.com/en-us/library/bcxfsh87.aspx).
In VS2008 the ToolsVersion is 3.5, but in VS2013 its 12.0.
I've attempted to make the ClassLibraryProject switch between 3.5 and 12.0 for the ToolsVersion with the following:
<Project ToolsVersion="$(ProjectToolsVersion)">
<Choose>
<When Condition="'$(VisualStudioVersion)' != ''">
<PropertyGroup>
<ProjectToolsVersion>12.0</ProjectToolsVersion>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<ProjectToolsVersion>3.5</ProjectToolsVersion>
</PropertyGroup>
</Otherwise>
</Choose>
<!-- other project stuff -->
</Project>
I can open this fine in VS2013, but when I open it in VS2008 it says:
Unable to read the project file 'ClassLibraryProject.csproj'.
C:\Test\ClassLibraryPorject.csproj: The tools version "$(ProjectToolsVersion)" is unrecognized.
Please Note: I am not able to migrate the entire project to VS2013 because VS2013 does not support Smart Device projects.
VS2008 which uses MSBuild 3.5 should be able to handle ToolsVersion 12, as in that case it automatically falls back to ToolsVersion 3.5.
Thus, you should migrate the class library project in VS2013, and it should be able to work still in the VS2008 solution without any modification.
VS2008 and MSBuild 3.5 gives you the error, because Choose is evaluated later than Project, so what you define in Choose (aka ProjectToolsVersion) cannot be used in Project.