Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to locate Microsoft.AspNet.Server.WebListener when running kpm restore

Tags:

asp.net-core

I copied the HelloMvc project folder to another folder "Ricky" and ran kpm restore, I got the following output: enter image description here

I have no idea what's wrong. the "kpm restore" ran successfully in its original folder which is cloned from the asp.net/home repository.

like image 857
Ricky Avatar asked May 20 '14 01:05

Ricky


1 Answers

Finally I figured out the solution. Thanks for the open source of ASP.NET vNext, I found out the source code of "restore" command.

During the restore process, the restore command tries to find out the "root" folder of the project by this method:

public static string ResolveRootDirectory(string projectDir)
{
    var di = new DirectoryInfo(projectDir);

    while (di.Parent != null)
    {
        if (di.EnumerateFiles("*.global.json").Any() ||
            di.EnumerateFiles("*.sln").Any() ||
            di.EnumerateDirectories("packages").Any() ||
            di.EnumerateDirectories(".git").Any())
        {
            return di.FullName;
        }

        di = di.Parent;
    }

    return Path.GetDirectoryName(projectDir);
}

because the HelloMvc folder doesn't have those files or packages folder, so the parent folder of HelloMvc will be the root folder.

The root folder is significant because we need to copy "NuGet.config" file to the root folder. The NuGet.config indicates the package source of "AspNetVNext", so assemblies of asp.net vNext can be found.

<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>

for myself, I created a packages folder in my HelloMvc folder and copied the NuGet.config to HelloMvc folder. So the HelloMvc folder itself is the root folder and NuGet.config is in position, the kpm restore succeeded.

like image 182
Ricky Avatar answered Nov 27 '22 11:11

Ricky