代码在本地进行构建,但是在构建定义中出现关于TF的构建错误 [英] Code getting build locally but Getting build erroron TF in build definition

查看:66
本文介绍了代码在本地进行构建,但是在构建定义中出现关于TF的构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个使用实体框架的项目,并且在本地运行良好.但是,当我尝试使用VSTS运行自动化构建时,在运行构建定义时出现错误.我知道它是由实体框架引用引起的,但我无法找到根本原因.这是构建错误以供参考.

I wrote a project that uses entity framework and is working fine locally. But when i try to run an automated build using VSTS I get am error while running build definition. I know it is getting caused by Entity framework reference but I am not able to get the root cause. Here is the build error for reference.

2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabase\Movies.Repository\MovieContext.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?)
2016-12-08T07:42:52.1197143Z MovieContext.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?) [C:\a\1\s\MyMovieDatabase\Movies.Repository\Movies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabase\Movies.Repository\MovieContext.cs(5,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
2016-12-08T07:42:52.1197143Z MovieContext.cs(5,19): error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [C:\a\1\s\MyMovieDatabase\Movies.Repository\Movies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabase\Movies.Repository\MovieContext.cs(7,29): Error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
2016-12-08T07:42:52.1197143Z MovieContext.cs(7,29): error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\MyMovieDatabase\Movies.Repository\Movies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabase\Movies.Repository\MovieContext.cs(17,33): Error CS0246: The type or namespace name 'CreateDatabaseIfNotExists' could not be found (are you missing a using directive or an assembly reference?)
2016-12-08T07:42:52.1197143Z MovieContext.cs(17,33): error CS0246: The type or namespace name 'CreateDatabaseIfNotExists' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\MyMovieDatabase\Movies.Repository\Movies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabase\Movies.Repository\MovieContext.cs(40,35): Error CS0246: The type or namespace name 'DbConfiguration' could not be found (are you missing a using directive or an assembly reference?)
2016-12-08T07:42:52.1197143Z MovieContext.cs(40,35): error CS0246: The type or namespace name 'DbConfiguration' could not be found (are you missing a using directive or an assembly reference?) [C:\a\1\s\MyMovieDatabase\Movies.Repository\Movies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabase\Movies.Repository\MovieRepository.cs(3,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
2016-12-08T07:42:52.1197143Z MovieRepository.cs(3,19): error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [C:\a\1\s\MyMovieDatabase\Movies.Repository\Movies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabase\Movies.Repository\MovieContext.cs(14,12): Error CS0246: The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?)

推荐答案

问题出在.csproject中的引用中,该引用使用本地引用(它取自硬盘中的packages文件夹).显然,将其部署在服务器中后将无法使用.将其更改为nugetpackages路径.以我在下面给出的格式更改所有引用的提示路径

The problem is in your Reference in .csproject which uses local reference(it takes from packages folder in your hard disk). Obviously This won't work when deployed in the server. Change that to the nugetpackages path. Change the Hint Path for all the references in the format I have given below

$(NugetPackagesPath)\EntityFramework.6.1.1\lib\net45\Entity‌​Framework.dll

您可以使用下面的代码定义NugetPackagesPath

You can use the below piece of code which defines the NugetPackagesPath

<PropertyGroup>
    <!-- EnlistmentRoot is the base directory where all of the module root directories reside. --> 
    <EnlistmentRoot>$(MSBuildThisFileDirectory)</EnlistmentRoot>
    <EnlistmentRoot Condition="'$(EnlistmentRoot)' != ''">$([System.IO.Path]::GetFullPath('$(EnlistmentRoot)'))</EnlistmentRoot>
    <EnlistmentRoot Condition="'$(EnlistmentRoot)' != '' and !HasTrailingSlash('$(EnlistmentRoot)')">$(EnlistmentRoot)\</EnlistmentRoot>
</PropertyGroup>
<PropertyGroup>
    <!-- NuGetPackagesPath is the base directory for all nuget packages. --> 
    <NuGetPackagesPath>$(EnlistmentRoot)Ref\Packages</NuGetPackagesPath>
    <NuGetPackagesPath Condition="'$(NuGetPackagesPath)' != ''">$([System.IO.Path]::GetFullPath('$(NuGetPackagesPath)'))</NuGetPackagesPath>
    <NuGetPackagesPath Condition="'$(NuGetPackagesPath)' != '' and !HasTrailingSlash('$(NuGetPackagesPath)')">$(NuGetPackagesPath)\</NuGetPackagesPath>
</PropertyGroup>

这篇关于代码在本地进行构建,但是在构建定义中出现关于TF的构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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