I created an ASP.NET Core Web Application in VS 2015. The Add unit tests checkbox was available for the ASP.NET 4.x templates, but when I selected ASP.NET 5 templates it was grayed out. I tried creating the project anyway with plans to add my own unit tests.
I added another project to the solution but I'm not able to link the two. When I right-click the references of the UnitTest project and hit Add Reference, I can see the original project as an option.
But when I check the box and hit OK, I get a dialog box that says, "A reference to 'PangolinWeb' could not be added. An assembly must have a 'dll' or 'exe' extension in order to be referenced."
Why can't I add an ASP.NET Core project as a reference? Is this the only way to make all of its classes and methods available to my UnitTest project?
The project still compiles to a dll that you can reference, so instead of referencing the project, reference the dll in the bin folder of the Core project
Add a reference to the file using the Add Reference, browse dialog
Edit the csproj to use a variable for the configuration so it builds in release mode correctly. e.g.
`
<Reference Include="YourLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\YourLibrary\bin\$(Configuration)\net45\YourLibrary.dll</HintPath>
</Reference>
You cannot add a ASP.NET 5 (ASP.NET Core) project as a reference to a .NET Framework .csproj project (which I presume your unit test project is). This is a feature gap in the current Visual Studio tooling but will be fixed (IMHO as part of the upcoming RC2). Why? Because it is not implemented ;).
I also want to highlight that the answer of Juliano is right. xUnit is the framework of choice, by the .NET and ASP.NET teams.
Solution ideas: Include the classes as a linked file into your csproj. Like that you can compile it twice and test it once. Not the finest solution but a workaround for a while till the tooling will catch up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With