I'm trying to build a console application in .NET vNext from Windows PowerShell. So far I have upgraded the package by
kvm upgrade
from which I got package version "KRE-svr50-x86.1.0.0-alpha3-10070" and also checked the "alias" to conform the version.
Now, I wrote a console app contains following lines:
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("Why Soo serious!!!! ");
}
}
and bellow the project.json
{
"dependencies": {
"System.Console": "4.0.0.0"
},
"configurations": {
"net45": {},
"k10": {}
}
}
And now, whenever I try to run this from Windows Poweshell it lists out missing dll (specifically namespace System) bellow the build output:
(both json and cs files in a same folder so no error related to json)
kpm build
(1,12): error CS0246: The type or namespace name 'System' could not found (are you missing a using directive or an assembly reference?)
How to refer the library. Please help me to find where(what) I'm missing and how to fix it...
Your problem is related to nuget configuration.
To see the way it works go to your project.json folder and do a "kpm restore". you will see:
Unable to locate System.Console >= 4.0.0.0
This happends because the kpm uses a different nugget repository namely: https://www.myget.org/F/aspnetvnext/
That repository has no nuget package for System.Console
To solve this you need a NuGet.Config file just outside your project.json folder in which you will specify the standard nuget repository (to get the System.Console package) and the asp.net vnext repository so you can get the asp.net vnext specific repositories.
That file should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/" />
<add key="NuGet.org" value="https://nuget.org/api/v2/" />
</packageSources>
<packageSourceCredentials>
<AspNetVNext>
<add key="Username" value="aspnetreadonly" />
<add key="ClearTextPassword" value="4d8a2d9c-7b80-4162-9978-47e918c9658c" />
</AspNetVNext>
</packageSourceCredentials>
</configuration>
Also look out for your folder structure:
/ - root folder
- NuGet.config
- your project folder
-- project.json
-- source code files
After you have created the folder structure as exemplified and put the NuGet.config in the right place you do a "kpm restore" and you will see that System.Console is resolved and then issuing "kpm build" all is building correctly
If you're still having this issue, and I was under 10.10, try changing your project.json file to this:
"dependencies": {
"System.Console": "4.0.0-beta-22210"
},
(mind you, that will have to be updated as System.Console is changed, but at least you'll be able to compile today).
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