可以在本地构建应用程序,但是在尝试在Azureure Devops管道中构建时会显示以下错误
我已经安装了EntityFramework并在webconfig文件中添加了system.data.entity.design程序集。
webapp\CaseDatabase.DataAccess\CaseAssignmentModule\CaseQueueDbAdapter.cs(10,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\CaseAssignmentModule\HoursEstDbAdapter.cs(4,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\CasesModule\CaseWorkflowDbAdapter.cs(2,17): Error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\ClientsAndContactsModule\ContactDefaultsDbAdapter.cs(5,17): Error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\ClientsAndContactsModule\InstructionLibraryDbAdapter.cs(4,17): Error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\DBEntityCoreModel\CaseDatabaseContext.cs(2,17): Error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\DBEntityCoreModel\ICaseDatabaseContext.cs(2,17): Error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\DBEntityCoreModel\ICaseDatabaseContext.cs(3,17): Error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\DBEntityCoreModel\ICaseDatabaseContext.cs(4,17): Error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
webapp\CaseDatabase.DataAccess\EntityRepository.cs(4,17): Error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
根据从@Stella共享的生成日志,此错误消息应由软件包还原路径引起。
首先,通过Nuget restore
任务还原相关的程序包全部成功。而且,所有需要的软件包都已还原。它的还原文件夹位置D:\a\1\s\webapp\Websites\packages
与Nuget.config中定义的位置相同..\packages
在Visual Studio Build
日志中,有以下消息:
Considered "..\ThirdParty\NuGetPackages\EntityFramework.6.1.2\lib\net45\EntityFramework.dll", but it didn't exist.
***
***
Considered "..\ThirdParty\NuGetPackages\EntityFramework.6.1.2\lib\net45\EntityFramework.SqlServer.dll", but it didn't exist.
***
***
***
根据在Visual Studio Build任务中显示的这些消息,您可以看到它正在文件夹路径下查找包位置..\ThirdParty\NuGetPackages
。正常情况下,此路径由来控制<HintPath>... </HintPath>
。
现在,很容易知道引起的错误:在构建过程中找到的程序包位置与其在Nuget restore
任务中实际恢复的程序包位置不匹配。
通常,其默认位置应为..\packages\...
,与中定义的默认位置相同Nuget.config
。我假设应该更改其本地存储库路径,然后HintPath
在csproj
文件中定义的路径也将自动更改。但是,在Nuget.config中,其程序包默认位置仍保持默认。这将导致在还原包时,它遵循中定义的位置Nuget.config
。但是在构建期间,由于它查找csproj
定义为...的软件包,因此构建无法知道实际的软件包还原位置。然后导致这些错误信息。
要解决此问题,有2个解决方案。
运行以下命令以重新安装所有软件包,从而将所有软件包HintPath
都更改为默认位置..\packages\...
,可以与Nuget.config中定义的同步。
Update-Package -reinstall
此解决方案的此逻辑被撤销HintPath
为默认位置,因此可以与中的定义保持同步Nuget.config
。
执行命令后,HintPath
外观应如下所示:
Nuget.config
文件第二溶液的逻辑是修改包的位置定义在Nuget.config
文件中。使它与同步HintPath
,此时,还原的软件包的位置将与构建时软件包的位置相同。
将以下脚本添加到Nuget.config文件中:
<configuration>
<config>
<add key="repositoryPath" value="xxxx" />
</config>
...
</configuration>
只需尝试一种解决方案,然后在本地Visual Studio中构建即可。它成功后,然后将它推入天青DEVOPS,构建与以前相同的任务配置use nuget
,nuget restore
,VS build
,publish artifacts
。
希望这可以帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句