I copied the HelloMvc project folder to another folder "Ricky" and ran kpm restore, I got the following output:
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.
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.
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