我试图构建一个存储在上的外部中的解决方案。
它有以下步骤:
1: Git还原工程 2: NuGet还原工程 3:构建-不工作
在查看日志时,我的第一个猜测是,MsBuild没有查找NuGet存储它们的包。NuGet还原中的一些行:
2018-03-14T21:10:11.0352862Z Completed installation of AngleSharp 0.9.9
2018-03-14T21:10:11.0353230Z Adding package 'AngleSharp.0.9.9' to folder 'D:\a\1\s\packages'
2018-03-14T21:10:11.0353563Z Added package 'AngleSharp.0.9.9' to folder 'D:\a\1\s\packages'
2018-03-14T21:10:11.0354972Z Added package 'AngleSharp.0.9.9' to folder 'D:\a\1\s\packages' from source 'https://api.nuget.org/v3/index.json' 'Microsoft.SharePointOnline.CSOM.16.1.7317.1200' to folder 'D:\a\1\s\packages'
来自MsBuild的一些行:
018-03-14T21:10:21.2105399Z PrepareForBuild:
2018-03-14T21:10:21.2105793Z Creating directory "bin\Release\".
2018-03-14T21:10:21.2424947Z Creating directory "obj\Release\".
2018-03-14T21:10:30.3569560Z ResolveAssemblyReferences:
2018-03-14T21:10:30.3570425Z Primary reference "AngleSharp, Version=0.9.9.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL".
2018-03-14T21:10:30.3670272Z ##[warning]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2041,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "AngleSharp, Version=0.9.9.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
我的解决方案/包结构是:
....\mysolution\myproject\myproject.csproj
....\mysolution\myproject\packages.config
当前的Config:
那么,我如何才能改变Nuget和/或msbuild-行为来实现这一目标呢?
(更新):要清除这个问题:每个包都有这个问题。它们都在packages.config中,每个都是从Nuget下载的,但也没有从MsBuild中找到
(Update2)当前生成的命令如下:
D:\a\_tool\NuGet\4.4.1\x64\nuget.exe restore D:\a\1\s\AweCsomeO365\packages.config -PackagesDirectory D:\a\1\a\packages -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\Nuget\tempNuGet_22.config
MSBUILD:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "D:\a\1\s\AweCsomeO365\AweCsomeO365.csproj" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_(GUID)\1.126.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=(GUID)|SolutionDir=D:\a\1\s\AweCsomeO365"*ForwardingLogger,"D:\a\_tasks\VSBuild_(GUID)\1.126.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=D:\a\1\a /p:ReferencePath=D:\a\1\a\packages /p:platform="anyCPU" /p:configuration="Release" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_(GUID)_build_4_22
我替换了GUID;VSTS似乎动态地生成了tempNuGetConfig。
还是这样。即使日志声明nuget存储包
Added package 'AngleSharp.0.9.9' to folder 'D:\a\1\a\packages'
MsBuild似乎没有在那里找到它们:
For SearchPath "D:\a\1\a\packages".
2018-03-16T13:57:42.4625155Z Considered "D:\a\1\a\packages\AngleSharp.winmd", but it didn't exist.
2018-03-16T13:57:42.4625456Z Considered "D:\a\1\a\packages\AngleSharp.dll", but it didn't exist.
2018-03-16T13:57:42.4625730Z Considered "D:\a\1\a\packages\AngleSharp.exe", but it didn't exist.
VSTS-配置值:
MsBuild:/p:ReferencePath=$(Build.StagingDirectory)\packages
Nuget-DestiantionDirectory:$(Build.StagingDirectory)\packages
(update3):我在存储库中没有-解决方案文件,但是只有一个csproj文件。
发布于 2018-03-23 01:30:19
问题是,在项目中有一个指向GIT-Repository (也不应该)的位置的包的隐藏路径:
<Reference Include="AngleSharp, Version=0.9.9.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL">
<HintPath>..\..\AweCsome365Test\packages\AngleSharp.0.9.9\lib\net45\AngleSharp.dll</HintPath>
</Reference>
我最初的方法是为NuGet定义一个目标目录,为MSBuild定义一个源目录,以便对两个都理解的包使用另一个位置。
但问题(据我所知)是,NuGet总是创建子文件夹结构的"./packages/{PackagesName}/lib/net45/{file}"
和MSBuild,在将"./packages"
设置为源路径时不会递归地显示。
以上只是对将来遇到同样问题的人的一个解释。
因此,我的解决方案是模仿nuget的本地行为,并更改输出目录以匹配HintPath (即使存储库中没有"AweCsome365Test")-directory:
(我将把这个问题留到一边,因为这个解决方案闻起来很可疑。如果有人有一个更好的解决方案,不需要使用HintPath就可以连锁nuget和msbuild,我很乐意花我的钱在它上)
发布于 2018-03-20 19:48:55
我相信你的MSBuild "ReferencePath“参数是不正确的。您正在告诉MS Build,您的所有引用(nuget包及其all包括在内)都将位于“D:\a\1\a\软件包”,但nuget并不会在那里下载和存储包和all。Nuget将下载并解压缩文件到D:\a\1\a\packages{packageName}{version}\lib{environment}\package.dll.中。我认为您需要从您的ReferencePath参数中删除最后一个参数( MSBuild )。
我还注意到,您的PackageLocation参数与NuGet还原任务的目标不相同,是否需要向该参数中添加"\packages“,如还原任务中的目标?
发布于 2018-03-22 12:36:27
将nuget还原目标目录更改为$(Build.SourcesDirectory)\packages,并删除msbuild参数。
https://stackoverflow.com/questions/49287852
复制