簡體   English   中英

代碼在本地進行構建,但是在構建定義中出現TF上的構建錯誤

[英]Code getting build locally but Getting build erroron TF in build definition

我寫了一個使用實體框架的項目,並且在本地運行良好。 但是,當我嘗試使用VSTS運行自動化構建時,在運行構建定義時出現錯誤。 我知道它是由實體框架引用引起的,但我無法找到根本原因。 這是構建錯誤以供參考。

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路徑。 以我下面給出的格式更改所有引用的提示路徑

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

您可以使用下面的代碼定義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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM