我有两个项目。项目1和项目2.项目1是指csproj文件中的项目2。我最近将项目2升级为更高版本的.NET。当我对项目1做同样的操作并运行我的CI管道时,我收到了很多错误,主要如下所示。当我分别为Proj 2运行CI管道时,它正在成功地构建。
我检查了所有可能的地方,看看是否有任何旧的参考资料,但我无法找到问题到底在哪里。谢谢你的帮助。
Done Building Project "D:\a\1\s\dia-praj2\src\Proj-2\Proj-2.csproj" (default targets).
##[warning]D:\a\1\s\dia-proj1\proj1.metaproj(0,0): Warning MSB3274: The primary reference "D:\a\1\s\dia-praj2\src\Proj-2\bin\Release\Proj-2.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.7.2"
##[warning]D:\a\1\s\dia-proj1\proj1.metaproj(0,0): Warning MSB3275: The primary reference "D:\a\1\s\dia-praj2\src\Proj-2\bin\Release\Proj-2.dll" could not be resolved because it has an indirect dependency on the assembly "CsvHelper, Version=27.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823" which was built against the ".NETFramework,Version=v4.7" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
##[warning]D:\a\1\s\dia-proj1\proj1.metaproj(0,0): Warning MSB3275: The primary reference "D:\a\1\s\dia-praj2\src\Proj-2\bin\Release\Proj-2.dll" could not be resolved because it has an indirect dependency on the assembly "Azure.Core, Version=1.22.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8" which was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
##[warning]D:\a\1\s\dia-proj1\proj1.metaproj(0,0): Warning MSB3275: The primary reference "D:\a\1\s\dia-praj2\src\Proj-2\bin\Release\Proj-2.dll" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" which was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".我的构建管道
a# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
pool:
vmImage: 'windows-latest'
variables:
solution: '**/Proj-1.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
name: $(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
resources:
repositories:
- repository: Proj-2
name: Proj-2
type: git
ref: feature/Proj-2
# this is being defined in app-ci pipeline
steps:
- script: echo '$(Build.BuildNumber)'
displayName: "echo build number"
- checkout: Proj-2
displayName: 'checkout Proj-2'
- checkout: self
displayName: 'checkout Proj-1'
- task: NuGetToolInstaller@1
displayName: Install Nuget Package Manager
- task: NuGetCommand@2
displayName: Restore Nuget packages
inputs:
command: 'restore'
restoreSolution: '$(solution)'
restoreDirectory: 'c:\packages'
- task: VSBuild@1
displayName: Build dia-ui solution
inputs:
solution: '$(solution)'
vsVersion: '16.0'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
clean: true
- task: CopyFiles@2
displayName: Copy everything to the Binaries dir
inputs:
Contents: '**/Prj1/abc/**'
TargetFolder: $(Build.BinariesDirectory)
- task: ArchiveFiles@2
displayName: Zip the binaries dir into a file called 'drop.zip'
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)/Prj1/abc/'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/drop.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
displayName: Publish 'drop.zip' as an artifact
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)/drop.zip'
ArtifactName: 'drop'发布于 2022-02-07 10:04:57
项目的依赖项与项目现在的.NET版本不匹配。我也遇到了同样的问题,并使用前面提到的这里方法重新安装了包。简而言之:在包管理器控制台中运行update-package <package name> -reinstall
在您更改.NET版本的项目中安装的所有包都要这样做。
https://stackoverflow.com/questions/70940176
复制相似问题