Visual Studio 数据库项目在本地计算机上构建,但在构建服务器上失败

Visual Studio database project builds on local machine, but fails on build server

我正在尝试为我的数据库项目设置 CI,但 运行 遇到了一个困扰我的问题。我能够在我的机器上成功构建项目;但是,当我签入对 TFS 的更改并且构建服务器尝试构建项目时,几乎每个 table 和存在的视图都会出现错误,如下所示:

Phase 1 - 11187 error(s), 556 warning(s)
SAS\dbo\Tables\CohortEntry.sql(12):SAS\dbo\Tables\CohortEntry.sql(12,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(14):SAS\dbo\Tables\CohortEntry.sql(14,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(16):SAS\dbo\Tables\CohortEntry.sql(16,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(18):SAS\dbo\Tables\CohortEntry.sql(18,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(20):SAS\dbo\Tables\CohortEntry.sql(20,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(22):SAS\dbo\Tables\CohortEntry.sql(22,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(24):SAS\dbo\Tables\CohortEntry.sql(24,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(26):SAS\dbo\Tables\CohortEntry.sql(26,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(28):SAS\dbo\Tables\CohortEntry.sql(28,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(30):SAS\dbo\Tables\CohortEntry.sql(30,1): Error SQL70001: This statement is not recognized in this context.
SAS\dbo\Tables\CohortEntry.sql(32):SAS\dbo\Tables\CohortEntry.sql(32,1): Error SQL70001: This statement is not recognized in this context.

此特定文件中失败的代码是:

CREATE TABLE [dbo].[CohortEntry] (
    [idCohortEntry] INT           IDENTITY (1, 1) NOT NULL,
    [CohortEntry]   NVARCHAR (50) NULL,
    [CohortLevel]   NVARCHAR (1)  CONSTRAINT [DF_CohortEntry_CohortLevel] DEFAULT (N'S') NOT NULL,
    [CohortCode]    NVARCHAR (3)  NOT NULL,
    CONSTRAINT [PK_CohortEntry] PRIMARY KEY CLUSTERED ([idCohortEntry] ASC)
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_DefaultView', @value = 2, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Contains one entry for every cohort of Students or Requests described by the SAS.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Filter', @value = NULL, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_OrderBy', @value = NULL, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_OrderByOn', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Orientation', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_TableMaxRecords', @value = 10000, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnHidden', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'idCohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnOrder', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'idCohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnWidth', @value = -1, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'idCohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'A unique serial key.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'idCohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnHidden', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnOrder', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnWidth', @value = 1815, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'A description for this cohort entry.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortEntry';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnHidden', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortLevel';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnOrder', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortLevel';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnWidth', @value = -1, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortLevel';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'A flag indicating whether this cohort entry refers to Student (S) or Request (R) cohorts.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortLevel';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnHidden', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortCode';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnOrder', @value = 0, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortCode';


GO
EXECUTE sp_addextendedproperty @name = N'MS_ColumnWidth', @value = -1, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortCode';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'The unique three-character code that defines this cohort.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'CohortEntry', @level2type = N'COLUMN', @level2name = N'CohortCode';

我不太确定问题出在哪里 - 非常感谢任何帮助。

实际上我最终弄清楚了,部分来自早期的附件 link。看起来所有导致错误的 SQL 文件都在文件末尾缺少 GO 流运算符 - 这似乎在每个 EXECUTE 命令之后都是必需的,即使在文件末尾也是如此。