无法在azure devops中构建asp.net应用程序 [英] unable to build a asp.net app in azure devops

查看:46
本文介绍了无法在azure devops中构建asp.net应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能够在本地构建应用程序,但是当尝试在azure devops管道中构建时.它在下面显示错误

我已经安装了EntityFramework并在webconfig文件中添加了system.data.entity.design程序集.

请在此处找到管道

NuGet还原任务

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中定义的默认位置相同.我假定应该更改其本地存储库路径,然后在csproj文件中定义的HintPath也将自动更改.但是,在Nuget.config中,其程序包默认位置仍保持默认.这将导致程序包还原时,它遵循Nuget.config中定义的位置.但是在构建期间,由于它查找定义了csproj ...的软件包,因此构建无法知道实际的软件包还原位置.然后导致这些错误消息.


要解决此问题,有2个解决方案.

  • 在Visual Studio中重新安装软件包

运行以下命令以重新安装所有,因此HintPath都可以更改为默认位置..\packages\...,可以与Nuget.config中定义的位置保持同步.

Update-Package -reinstall

此解决方案的此逻辑被撤销HintPath作为默认位置,因此它可以与Nuget.config中的定义保持同步.

执行命令后,HintPath的外观应与此相同:

  • 修改Nuget.config文件

第二种解决方案的逻辑是

只需尝试一种解决方案,然后在本地的Visual Studio中进行构建.成功后,将其推送到Azure Devops中,并使用与以前相同的任务配置use nugetnuget restoreVS buildpublish artifacts进行构建.

希望这会有所帮助.

Able to build the app locally, but when am trying to build in azure devops pipeline.It showing below errors

I have installed EntityFramework and added system.data.entity.design assembly in webconfig file.No luck

Please find pipeline here

NuGet Restore task

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?)

解决方案

According to the build log which shared from @Stella, this error message should caused by the package restored path.

Firstly, it's all succeed to restore the relevant package with the Nuget restore task. And also, the packages needed all has been restored. It's restored folder location is D:\a\1\s\webapp\Websites\packages which same with location defined in Nuget.config ..\packages

In the Visual Studio Build log, there has the following message:

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.
***
***
***

According to these message which displayed in Visual Studio Build task, you can see it is finding the package location under the folder path ..\ThirdParty\NuGetPackages. As normal, this path is controlled by the <HintPath>... </HintPath>.

Now, it would be very easy to know the error caused: the package location which found during the build does not match with its actually package restored location in Nuget restore task.

As normal, its default location should be ..\packages\..., which same with default location defined in Nuget.config. I assume its local repos path should ever be changed, then its HintPath which defined in csproj file are also be changed automatically. But, in Nuget.config, its package default location are still keep default. That will cause when package restore, it follow the location defined in Nuget.config. But during build time, since it look for the package with the csproj ... defined, build can not know the actually package restored location. Then caused these error message.


To solve this issue, there has 2 solutions.

  • Reinstall packages in Visual Studio

Run the below command to reinstall all of packages, thus the HintPath can all changed into default location ..\packages\..., which can sync with defined in Nuget.config.

Update-Package -reinstall

This logic of this solution is revoke HintPath as default location, thus it can keep sync with definition in Nuget.config.

After execute the command, the HintPath should same look as this:

  • Modify the Nuget.config file

The logic of second solution is modify the package location definition in Nuget.config file. Make it sync with HintPath, at this time, the location of the package restored will be the same as the location of the package at build time.

Add the following script into Nuget.config file:

<configuration>
  <config>
    <add key="repositoryPath" value="xxxx" />
  </config>
  ... 
</configuration>

Just try with one solution, then build in Visual Studio locally. After it is succeed, then push it into Azure Devops, build with the same task configuration previously, use nuget, nuget restore, VS build, publish artifacts.

Hope this helps.

这篇关于无法在azure devops中构建asp.net应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆