Find out why ASP. NET 5 appears & quot; The following projects are not supported as references: & quot; **. csproj & quot;, references. csproj

Source: Internet
Author: User

Find out why ASP. NET 5 appears "The following projects are not supported as references:" **. csproj "", references. csproj

VS2015 Preview has been released for some time. According to the official statement, ASP. NET 5 has made some major improvements and designs.

The optimized development framework has the following features:

  • It supports cross-platform running, not only running on Windows, but also running on Mono platform. NET, and operating systems such as Unix, Windows, and MacOS.
  • Different from previous HTTP request pipelines, they can be managed and managed on IIS.
  • A unified programming model that combines MVC, Web Api, and Web Pages.
  • You can see the modification effect without building.
  • It is open-source on github and can be downloaded to some applications.

...

I believe some of my friends have found more changes in asp.net 5 than I have. Some major changes have been made in this regard, and Microsoft has really overturned itself, this is also an area worth your expectation and progress. It is also an ideal choice for Building web applications. So in the course of learning asp.net 5, I believe that my friends who love technology have encountered the same problem as me. in Visual Studio 2015 Preview beta1, there is no way to get the ASP. NET 5 project references the previous version of the csproj project. When we reference the class library, an error message is displayed as follows:

 

The following items cannot be referenced: **. csproj. As the name implies, the version is incompatible. How can we achieve version compatibility? There must be some methods, such as releasing NuGet packages or performing version migration. I believe some friends are not familiar with releasing NuGet packages, so let's learn about version migration. [Note: Version migration is translated by the author based on his own understanding.]

Install KVM (K Version Manager)

You need to run the following command on Windows Cmd.exe or VS Cmd.exe, which will download and run the command to install KVM on the current user. (Administrator permissions required)

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.ps1'))" 

If the installation is successful, as shown in:

Then input the following in the command line:

kpm wrap .\src\ClassLibrary

The result is as follows:

In this case, you can modify the project. json file:

... "dependencies": { "ClassLibrary": "" }, ... 

A friend of good English can take a look at the original article below!

Visual Studio 2015 Preview (as of writing this) comes with the ASP. NET 5 stable release beta1. In this version there is no way to reference a csproj project from an ASP. NET 5 project.

However, on the development feed of ASP. NET 5 the commandkpm wrapWas introduced to support referencing csproj-projects from ASP. NET 5 projects. See the github issue #827 in the aspnet/KRuntime repository and pull request #875 which closes the issue.

Here is an example how you wocould usekpm wrap:

Make sure the newest version of the KRuntime is installed (check this withkvm listCommand) (I tested this with version1.0.0-beta2-10709).

Create an ASP. NET 5 class library project, I used the name ClassLibrary1.

Create a "normal" csproj class library, I named this ClassLibrary2 (make sure you put this in the src folder ).

From the commandline, fromSolution directoryRun the command

kpm wrap .\src\ClassLibrary2

This gives the output:

Wrapping project 'ClassLibrary2' for '.NETFramework,Version=v4.5' Source C:\Users\andersns\Source\ClassLibrary1\src\ClassLibrary2\ClassLibrary2.csproj   Target C:\Users\andersns\Source\ClassLibrary1\wrap\ClassLibrary2\project.json   Adding bin paths for '.NETFramework,Version=v4.5'     Assembly: ../../src/ClassLibrary2/obj/debug/ClassLibrary2.dll     Pdb: ../../src/ClassLibrary2/obj/debug/ClassLibrary2.pdb

 

Now in the project. json of ClassLibrary1 (which is ASP. NET 5) you can add a reference to ClassLibrary2 with this:

..."dependencies": {    "ClassLibrary2": ""},...

 

Note:kpm wrapDid not run properly for me with cmd, I needed to launch powershell to make it run.

 

By the way, Visual Studio 2015 Preview beta2 has been improved and supports referencing C # standard projects.

Link: http://blogs.msdn.com/ B /visualstudio/archive/2015/01/16/visual-studio-2015-cpt-5-now-available.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.