C# 从源代码生成Microsoft.AspNet.Identity,解析包时引发错误
我正试图从中可用的源代码建立一个网络身份。它在构建过程中抛出错误。复制步骤:C# 从源代码生成Microsoft.AspNet.Identity,解析包时引发错误,c#,visual-studio,nuget,asp.net-identity-2,C#,Visual Studio,Nuget,Asp.net Identity 2,我正试图从中可用的源代码建立一个网络身份。它在构建过程中抛出错误。复制步骤: 启动Visual Studio 2019社区并选择克隆存储库。输入以下URL并单击克隆: 将nuget.exe复制到克隆项目中的.nuget目录 构建解决方案 输出为: 1>------ Build started: Project: Microsoft.AspNet.Identity.EntityFramework, Configuration: Debug Any CPU ------ 2>-----
.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
从源代码生成Microsoft.AspNet.Identity,在
解析包
该问题位于numget.targets
文件的restorecomand
下
和默认情况下,SolutionDir
属性包含\
。在命令中,它将使MSBuild无法找到包地址
除此之外,我注意到:
-solutionDir“$(solutionDir)”
SolutionDir
和“
之间有一个空格,您应该删除它
解决方案
更改为在nuget.targets
文件中使用此选项:
<SolutionDir1>$(SolutionDir.Trim('\'))</SolutionDir1>
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir1)"</RestoreCommand>
$(SolutionDir.Trim('\'))
$(NuGetCommand)安装“$(PackageConfig)”-源“$(PackageSources)”$(RequiredSentSwitch)-solutionDir“$(SolutionDir1)”
完成后,应关闭VS,然后重新启动项目以重新加载新的csproj文件以启用更改
注意:使用一个新属性
SolutionDir1
,该属性将删除该\
,然后在命令中使用它。问题来自nuget.targets
文件的RestoreCommand
。默认情况下,solutiondir
属性包含\。在命令中,它将使MSBuild无法找到程序包地址。因此您应该删除该\。我将添加一个答案以帮助您解决此问题。