代码在本地获得构建,但在构建定义中获得构建错误tf



我写了一个使用实体框架并在本地工作正常的项目。但是,当我尝试使用VST运行自动构建时,我在运行构建定义时会出现AM错误。我知道它是由实体框架参考引起的,但我无法获得根本原因。这是引用的构建错误。

2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabaseMovies.RepositoryMovieContext.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:a1sMyMovieDatabaseMovies.RepositoryMovies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabaseMovies.RepositoryMovieContext.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:a1sMyMovieDatabaseMovies.RepositoryMovies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabaseMovies.RepositoryMovieContext.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:a1sMyMovieDatabaseMovies.RepositoryMovies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabaseMovies.RepositoryMovieContext.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:a1sMyMovieDatabaseMovies.RepositoryMovies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabaseMovies.RepositoryMovieContext.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:a1sMyMovieDatabaseMovies.RepositoryMovies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabaseMovies.RepositoryMovieRepository.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:a1sMyMovieDatabaseMovies.RepositoryMovies.Repository.csproj]
2016-12-08T07:42:52.1197143Z ##[error]MyMovieDatabaseMovies.RepositoryMovieContext.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?)

问题在您的参考中,使用局部参考(它取自硬盘中的包装文件夹)。显然,当部署在服务器中时,这将不起作用。将其更改为NugetPackages路径。更改我以下给出的所有格式中所有参考的提示路径

$(NugetPackagesPath)EntityFramework.6.1.1libnet45Entity‌​Framework.dll

您可以使用以下代码来定义NugetPackages Pathe

<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)RefPackages</NuGetPackagesPath>
    <NuGetPackagesPath Condition="'$(NuGetPackagesPath)' != ''">$([System.IO.Path]::GetFullPath('$(NuGetPackagesPath)'))</NuGetPackagesPath>
    <NuGetPackagesPath Condition="'$(NuGetPackagesPath)' != '' and !HasTrailingSlash('$(NuGetPackagesPath)')">$(NuGetPackagesPath)</NuGetPackagesPath>
</PropertyGroup>

相关内容

最新更新