我有一个c# Web API的DevOps管道,在nuget恢复完成并运行vsbuild命令后找不到nuget包。
下面是YAML文件:trigger:
- dev
pool:
vmImage: 'windows-latest'
variables:
solution: 'WebAPI/myWebAPI/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'config'
nugetConfigPath: 'WebAPI/myWebAPI/myWebAPI/nuget.config'
restoreDirectory: '$(Build.SourcesDirectory)/WebAPI/myWebAPI/packages'
- task: CmdLine@2
inputs:
script: 'ls -Rla'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
msbuildArgs: '/p:ReferencePath="$(Build.SourcesDirectory)/WebAPI/myWebAPI/packages" /p:RestorePackagesConfig=true /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
configuration: '$(buildConfiguration)'
当我在DevOps中运行这个YAML时,VSBuild任务无法找到带有日志记录的nuget包,看起来像这样…
"D:a_tasksVSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda1.199.0ps_modulesMSBuildHelpersvswhere.exe" -version [17.0,18.0) -latest -format json
"C:Program FilesMicrosoft Visual Studio2022EnterpriseMSBuildCurrentBinmsbuild.exe" "D:a1sWebAPImyWebAPImyWebAPI.sln" /nologo /nr:false /dl:CentralLogger,"D:a_tasksVSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda1.199.0ps_modulesMSBuildHelpersMicrosoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=7bbf82be-4773-4dce-8327-de23d86dafd6|SolutionDir=D:a1sWebAPImyWebAPI|enableOrphanedProjectsLogs=true"*ForwardingLogger,"D:a_tasksVSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda1.199.0ps_modulesMSBuildHelpersMicrosoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:platform="Any CPU" /p:configuration="Release" /p:VisualStudioVersion="17.0" /p:_MSDeployUserAgent="VSTS_704c3632-77a5-4025-9f8d-47b795f1f578_build_41_0"
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 6/27/2022 10:57:43 PM.
Project "D:a1sWebAPImyWebAPImyWebAPI.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Release|Any CPU".
Project "D:a1sWebAPImyWebAPImyWebAPI.sln" (1) is building "D:a1sWebAPImyWebAPImyWebAPImyWebAPI.csproj" (2) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin".
Creating directory "objRelease".
ResolveAssemblyReferences:
Primary reference "DevExpress.Web.ASPxThemes.v21.1, Version=21.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL".
##[warning]C:Program FilesMicrosoft Visual Studio2022EnterpriseMSBuildCurrentBinMicrosoft.Common.CurrentVersion.targets(2302,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "DevExpress.Web.ASPxThemes.v21.1, Version=21.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:Program FilesMicrosoft Visual Studio2022EnterpriseMSBuildCurrentBinMicrosoft.Common.CurrentVersion.targets(2302,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "DevExpress.Web.ASPxThemes.v21.1, Version=21.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:a1sWebAPImyWebAPImyWebAPImyWebAPI.csproj]
For SearchPath "{TargetFrameworkDirectory}".
Considered "C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.8DevExpress.Web.ASPxThemes.v21.1.winmd", but it didn't exist.
Considered "C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.8DevExpress.Web.ASPxThemes.v21.1.dll", but it didn't exist.
Considered "C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.8DevExpress.Web.ASPxThemes.v21.1.exe", but it didn't exist.
VSBuild任务失败,因为它没有找到nuget包,所以在构建期间名称空间不存在。项目中发生的所有包。我添加了一个任务来列出目录内容,目录结构与我在本地构建Visual Studio项目时相同。它在本地也可以很好地构建。
有人能帮忙吗?你知道我还能做些什么吗?
问题最终是我不得不将DevExpress更新到21.2.6版本,然后手动将下面的2行添加到包中。配置文件。然后DevOps管道工作了。
<package id="DevExpress.Web.Mvc5" version="21.2.6" targetFramework="net48" />
<package id="DevExpress.Web.Mvc5.Dashboard" version="21.2.6" targetFramework="net48" />