从源代码构建 Microsoft.AspNet.Identity,解析包时抛出错误
Build Microsoft.AspNet.Identity from source, throws error when resolving packages
我正在尝试从 https://github.com/aspnet/AspNetIdentity 中提供的源代码构建 AspNetIdentity。它在构建过程中抛出错误。重现步骤:
- 启动 Visual Studio 2019 社区和 select
Clone a repository
。输入以下 URL 并单击 Clone
:
https://github.com/aspnet/AspNetIdentity.git
- 将nuget.exe复制到克隆项目中的
.nuget
目录。
- 构建解决方案。
输出为:
1>------ Build started: Project: Microsoft.AspNet.Identity.EntityFramework, Configuration: Debug Any CPU ------
2>------ Build started: Project: Microsoft.AspNet.Identity.Owin, Configuration: Debug Any CPU ------
2> Restoring NuGet packages...
2> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages'.
2> Feeds used:
2> C:\Users\MyUserName\.nuget\packages\
2> http://myget.org/F/owin
2> https://nuget.org/api/v2/
2>
2> Restoring NuGet package Microsoft.Owin.3.0.1.
2> Restoring NuGet package Microsoft.Owin.Security.Cookies.3.0.1.
2> Restoring NuGet package Microsoft.Owin.Security.3.0.1.
2> Restoring NuGet package Microsoft.Owin.Security.OAuth.3.0.1.
2> Adding package 'Microsoft.Owin.Security.Cookies.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2> Adding package 'Microsoft.Owin.Security.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2> Adding package 'Microsoft.Owin.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2> Adding package 'Microsoft.Owin.Security.OAuth.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.Cookies.3.0.1'.
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.3.0.1'.
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.3.0.1'.
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.OAuth.3.0.1'.
2> Restoring NuGet package Newtonsoft.Json.6.0.4.
2> Restoring NuGet package Owin.1.0.0.
2> Adding package 'Newtonsoft.Json.6.0.4' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2> Adding package 'Owin.1.0.0' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Owin.1.0'.
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Newtonsoft.Json.6.0.4'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.Cookies.3.0.1'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.OAuth.3.0.1'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.3.0.1'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.3.0.1'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Owin.1.0'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Newtonsoft.Json.6.0.4'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error MSB3073: The command ""C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.exe" install "C:\Users\MyUserName\Source\Repos\AspNetIdentity\src\Microsoft.AspNet.Identity.Owin\packages.config" -source "http://myget.org/F/owin;https://nuget.org/api/v2/" -RequireConsent -solutionDir "C:\Users\MyUserName\Source\Repos\AspNetIdentity\ "" exited with code 1.
1> Restoring NuGet packages...
1> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages'.
1> Feeds used:
1> C:\Users\MyUserName\.nuget\packages\
1> http://myget.org/F/owin
1> https://nuget.org/api/v2/
1>
1> Restoring NuGet package EntityFramework.6.1.1.
1> Adding package 'EntityFramework.6.1.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
1>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\EntityFramework.6.1.1'.
1>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\EntityFramework.6.1.1'.
1>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error MSB3073: The command ""C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.exe" install "C:\Users\MyUserName\Source\Repos\AspNetIdentity\src\Microsoft.AspNet.Identity.EntityFramework\packages.config" -source "http://myget.org/F/owin;https://nuget.org/api/v2/" -RequireConsent -solutionDir "C:\Users\MyUserName\Source\Repos\AspNetIdentity\ "" exited with code 1.
3>------ Build started: Project: Identity.Test, Configuration: Debug Any CPU ------
3> Restoring NuGet packages...
3> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages'.
3> Feeds used:
3> C:\Users\MyUserName\.nuget\packages\
3> http://myget.org/F/owin
3> https://nuget.org/api/v2/
3>
3> Restoring NuGet package Microsoft.Owin.Security.Cookies.3.0.1.
3> Restoring NuGet package Microsoft.Owin.Security.3.0.1.
3> Restoring NuGet package Microsoft.Owin.3.0.1.
3> Restoring NuGet package EntityFramework.6.1.1.
3> Adding package 'Microsoft.Owin.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'Microsoft.Owin.Security.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'Microsoft.Owin.Security.Cookies.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'EntityFramework.6.1.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.3.0.1'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\EntityFramework.6.1.1'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.Cookies.3.0.1'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.3.0.1'.
3> Restoring NuGet package Moq.4.0.10827.
3> Restoring NuGet package Owin.1.0.0.
3> Restoring NuGet package xunit.extensions.1.9.2.
3> Restoring NuGet package xunit.1.9.2.
3> Adding package 'Owin.1.0.0' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'Moq.4.0.10827' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'xunit.extensions.1.9.2' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'xunit.1.9.2' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Owin.1.0'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\xunit.extensions.1.9.2'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\xunit.1.9.2'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Moq.4.0.10827'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.Cookies.3.0.1'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\EntityFramework.6.1.1'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.3.0.1'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.3.0.1'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Owin.1.0'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\xunit.extensions.1.9.2'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\xunit.1.9.2'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Moq.4.0.10827'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error MSB3073: The command ""C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.exe" install "C:\Users\MyUserName\Source\Repos\AspNetIdentity\test\Identity.Test\packages.config" -source "http://myget.org/F/owin;https://nuget.org/api/v2/" -RequireConsent -solutionDir "C:\Users\MyUserName\Source\Repos\AspNetIdentity\ "" exited with code 1.
========== Build: 0 succeeded, 3 failed, 1 up-to-date, 0 skipped ==========
以下包含\ \
部分的目录路径似乎有问题,但我不知道为什么它包含在路径中:
C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Moq.4.0.10827
Build Microsoft.AspNet.Identity from source, throws error when
resolving packages
问题出在 nuget.targets
文件的 RestoreCommand
下。
和默认情况下,SolutionDir
属性包含\
。并且在命令中,会让MSBuild找不到包地址
除此之外,我注意到:
-solutionDir "$(SolutionDir) "</RestoreCommand>
SolutionDir
和"
之间有一个space,你应该删除它。
解决方案
更改为在 nuget.targets
文件中使用它:
<SolutionDir1>$(SolutionDir.Trim('\'))</SolutionDir1>
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir1)"</RestoreCommand>
完成后,您应该关闭 VS,然后重新启动您的项目 以重新加载新的 csproj 文件以启用您的更改。
注意:使用新的 属性 SolutionDir1
删除 \
然后在命令中使用它。
我正在尝试从 https://github.com/aspnet/AspNetIdentity 中提供的源代码构建 AspNetIdentity。它在构建过程中抛出错误。重现步骤:
- 启动 Visual Studio 2019 社区和 select
Clone a repository
。输入以下 URL 并单击Clone
: https://github.com/aspnet/AspNetIdentity.git - 将nuget.exe复制到克隆项目中的
.nuget
目录。 - 构建解决方案。
输出为:
1>------ Build started: Project: Microsoft.AspNet.Identity.EntityFramework, Configuration: Debug Any CPU ------
2>------ Build started: Project: Microsoft.AspNet.Identity.Owin, Configuration: Debug Any CPU ------
2> Restoring NuGet packages...
2> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages'.
2> Feeds used:
2> C:\Users\MyUserName\.nuget\packages\
2> http://myget.org/F/owin
2> https://nuget.org/api/v2/
2>
2> Restoring NuGet package Microsoft.Owin.3.0.1.
2> Restoring NuGet package Microsoft.Owin.Security.Cookies.3.0.1.
2> Restoring NuGet package Microsoft.Owin.Security.3.0.1.
2> Restoring NuGet package Microsoft.Owin.Security.OAuth.3.0.1.
2> Adding package 'Microsoft.Owin.Security.Cookies.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2> Adding package 'Microsoft.Owin.Security.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2> Adding package 'Microsoft.Owin.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2> Adding package 'Microsoft.Owin.Security.OAuth.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.Cookies.3.0.1'.
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.3.0.1'.
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.3.0.1'.
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.OAuth.3.0.1'.
2> Restoring NuGet package Newtonsoft.Json.6.0.4.
2> Restoring NuGet package Owin.1.0.0.
2> Adding package 'Newtonsoft.Json.6.0.4' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2> Adding package 'Owin.1.0.0' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Owin.1.0'.
2>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Newtonsoft.Json.6.0.4'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.Cookies.3.0.1'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.OAuth.3.0.1'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.3.0.1'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.3.0.1'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Owin.1.0'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Newtonsoft.Json.6.0.4'.
2>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error MSB3073: The command ""C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.exe" install "C:\Users\MyUserName\Source\Repos\AspNetIdentity\src\Microsoft.AspNet.Identity.Owin\packages.config" -source "http://myget.org/F/owin;https://nuget.org/api/v2/" -RequireConsent -solutionDir "C:\Users\MyUserName\Source\Repos\AspNetIdentity\ "" exited with code 1.
1> Restoring NuGet packages...
1> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages'.
1> Feeds used:
1> C:\Users\MyUserName\.nuget\packages\
1> http://myget.org/F/owin
1> https://nuget.org/api/v2/
1>
1> Restoring NuGet package EntityFramework.6.1.1.
1> Adding package 'EntityFramework.6.1.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
1>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\EntityFramework.6.1.1'.
1>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\EntityFramework.6.1.1'.
1>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error MSB3073: The command ""C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.exe" install "C:\Users\MyUserName\Source\Repos\AspNetIdentity\src\Microsoft.AspNet.Identity.EntityFramework\packages.config" -source "http://myget.org/F/owin;https://nuget.org/api/v2/" -RequireConsent -solutionDir "C:\Users\MyUserName\Source\Repos\AspNetIdentity\ "" exited with code 1.
3>------ Build started: Project: Identity.Test, Configuration: Debug Any CPU ------
3> Restoring NuGet packages...
3> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages'.
3> Feeds used:
3> C:\Users\MyUserName\.nuget\packages\
3> http://myget.org/F/owin
3> https://nuget.org/api/v2/
3>
3> Restoring NuGet package Microsoft.Owin.Security.Cookies.3.0.1.
3> Restoring NuGet package Microsoft.Owin.Security.3.0.1.
3> Restoring NuGet package Microsoft.Owin.3.0.1.
3> Restoring NuGet package EntityFramework.6.1.1.
3> Adding package 'Microsoft.Owin.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'Microsoft.Owin.Security.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'Microsoft.Owin.Security.Cookies.3.0.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'EntityFramework.6.1.1' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.3.0.1'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\EntityFramework.6.1.1'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.Cookies.3.0.1'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.3.0.1'.
3> Restoring NuGet package Moq.4.0.10827.
3> Restoring NuGet package Owin.1.0.0.
3> Restoring NuGet package xunit.extensions.1.9.2.
3> Restoring NuGet package xunit.1.9.2.
3> Adding package 'Owin.1.0.0' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'Moq.4.0.10827' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'xunit.extensions.1.9.2' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3> Adding package 'xunit.1.9.2' to folder 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages'
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Owin.1.0'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\xunit.extensions.1.9.2'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\xunit.1.9.2'.
3>EXEC : warning : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Moq.4.0.10827'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.Cookies.3.0.1'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\EntityFramework.6.1.1'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.3.0.1'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Microsoft.Owin.Security.3.0.1'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Owin.1.0'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\xunit.extensions.1.9.2'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\xunit.1.9.2'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error : Could not find a part of the path 'C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Moq.4.0.10827'.
3>C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.targets(89,9): error MSB3073: The command ""C:\Users\MyUserName\Source\Repos\AspNetIdentity\.nuget\nuget.exe" install "C:\Users\MyUserName\Source\Repos\AspNetIdentity\test\Identity.Test\packages.config" -source "http://myget.org/F/owin;https://nuget.org/api/v2/" -RequireConsent -solutionDir "C:\Users\MyUserName\Source\Repos\AspNetIdentity\ "" exited with code 1.
========== Build: 0 succeeded, 3 failed, 1 up-to-date, 0 skipped ==========
以下包含\ \
部分的目录路径似乎有问题,但我不知道为什么它包含在路径中:
C:\Users\MyUserName\Source\Repos\AspNetIdentity\ \packages\Moq.4.0.10827
Build Microsoft.AspNet.Identity from source, throws error when resolving packages
问题出在 nuget.targets
文件的 RestoreCommand
下。
和默认情况下,SolutionDir
属性包含\
。并且在命令中,会让MSBuild找不到包地址
除此之外,我注意到:
-solutionDir "$(SolutionDir) "</RestoreCommand>
SolutionDir
和"
之间有一个space,你应该删除它。
解决方案
更改为在 nuget.targets
文件中使用它:
<SolutionDir1>$(SolutionDir.Trim('\'))</SolutionDir1>
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir1)"</RestoreCommand>
完成后,您应该关闭 VS,然后重新启动您的项目 以重新加载新的 csproj 文件以启用您的更改。
注意:使用新的 属性 SolutionDir1
删除 \
然后在命令中使用它。