Closed bheemvennapureddy closed 3 months ago
@ErikEJ does these inputs help ?
Post-deployment file
/*
POST-Deployment Script Template
--------------------------------------------------------------------------------------
This file contains SQL statements that will be appended to the build script.
Use SQLCMD syntax to include a file in the post-deployment script.
Example: :r .\myfile.sql
Use SQLCMD syntax to reference a variable in the post-deployment script.
Example: :setvar TableName MyTable
SELECT * FROM [$(TableName)]
--------------------------------------------------------------------------------------
*/
DECLARE @ReleaseVersion decimal(10,2) = 2427.0
DECLARE @ScriptStartTime datetime = GETDATE()
DECLARE @CurrentVersion DECIMAL(10,2)
BEGIN TRY
PRINT 'POST DEPLOYMENT START TIME: ' + CONVERT(VARCHAR(30), GETDATE(), 109)
SET NOCOUNT ON;
IF EXISTS (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'Global')
BEGIN
SELECT @CurrentVersion = CONVERT(DECIMAL(10,2),RTRIM(LTRIM(APP_VERSION))) FROM [Global]
END
SET @CurrentVersion = ISNULL(@CurrentVersion, 0.0)
PRINT 'Current version is: ' + ISNULL(CAST(@CurrentVersion AS VARCHAR),'Not Available')
PRINT 'BEGIN POST DEPLOYMENT SCRIPTS'
IF @CurrentVersion < @ReleaseVersion
BEGIN
PRINT 'Begin ' + Cast(@ReleaseVersion as varchar(12)) + ' Post-Deployment'
:r "Post-Deployment/2427.0-PostDeployment.sql"
PRINT 'End ' + Cast(@ReleaseVersion as varchar(12)) + ' Post-Deployment' + CONVERT(VARCHAR(30), GETDATE(), 109)
UPDATE [Global] SET APP_VERSION = @ReleaseVersion
END
PRINT 'END POST DEPLOYMENT SCRIPTS'
SET NOCOUNT OFF;
BEGIN
DECLARE @MSG varchar(4000), @ElapsedTime VARCHAR(100)
-- Get elapsed time
SET @ElapsedTime = CAST(ROUND(CAST(DATEDIFF(ms, @ScriptStartTime, GETDATE()) AS float) / 1000, 3) AS varchar(32)) + 's'
SET @MSG = 'FINISHED PROCESSING OF POST-DEPLOYMENT INCREMENTAL SCRIPTS in ' + @ElapsedTime
RAISERROR(@MSG, 1, 1) WITH NOWAIT;
END
PRINT 'POST DEPLOYMENT END TIME: ' + CONVERT(VARCHAR(30), GETDATE(), 109)
END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;
SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();
RAISERROR('UNABLE TO COMPLETE PROCESSING OF POST-DEPLOYMENT INCREMENTAL SCRIPTS', 1, 1) WITH NOWAIT;
RAISERROR ( @ErrorMessage,
@ErrorSeverity,
@ErrorState
) WITH NOWAIT;
END CATCH
/*
Safely run foreign key checks. The SSDT foriegn key check can fail for pre-existing invalid keys, which will fail the script. This continues if there is a check failure.
This is only needed for projects that have the 'Script validation for new constraints' option set to false.
*/
declare @fkName nvarchar(254)
declare @fkCheckCommand nvarchar(1000)
DECLARE untrustedForeignKeys CURSOR FOR
select
N'ALTER TABLE ' + object_name(fk.parent_object_id) + ' WITH CHECK CHECK CONSTRAINT ' + object_name(fk.object_id) as CheckCommand
, object_name(fk.object_id) as FkName
--, object_name(fk.parent_object_id) as ParentTable, object_name(fk.referenced_object_id) as ReferencedTable, T1.FkColumns, T1.ReferencedColumns
from (
select fk.object_id
, STRING_AGG(COL_NAME(fkc.parent_object_id, fkc.parent_column_id), ',') as FkColumns
, STRING_AGG(COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id), ',') as ReferencedColumns
from sys.foreign_keys fk
inner join sys.foreign_key_columns fkc on fkc.constraint_object_id = fk.object_id
where is_not_trusted = 1
group by fk.object_id
) T1
inner join sys.foreign_keys fk on fk.object_id = t1.object_id
order by fk.name
OPEN untrustedForeignKeys
BEGIN TRY
FETCH NEXT FROM untrustedForeignKeys
INTO @fkCheckCommand, @fkName
WHILE @@FETCH_STATUS = 0
BEGIN
BEGIN TRY
PRINT 'Checking ' + @fkName
exec sp_executesql @statement=@fkCheckCommand
END TRY
BEGIN CATCH
print 'Error Number: ' + cast(ERROR_NUMBER() as varchar(10)) + ' Error Severity: ' + cast(ERROR_SEVERITY() as varchar(10)) + ' Error State: ' + cast(ERROR_STATE() as varchar(10)) + ' Error Procedure: ' + ERROR_PROCEDURE() + ' Error Message: ' + ERROR_MESSAGE()
END CATCH
FETCH NEXT FROM untrustedForeignKeys
INTO @fkCheckCommand, @fkName
END
CLOSE untrustedForeignKeys;
DEALLOCATE untrustedForeignKeys;
END TRY
BEGIN CATCH
CLOSE untrustedForeignKeys;
DEALLOCATE untrustedForeignKeys;
THROW;
END CATCH
The build action for these items should be None, not "Content"
<ItemGroup>
<Content Remove="Scripts\Post-Deployment\2427.0-PreDeployment.sql" />
<Content Remove="Scripts\Pre-Deployment\2427.0-PostDeployment.sql" />
</ItemGroup>
You mean they shouldn’t be in the project file or just do a none include ?
None Include
Still see the same error
Please share the full modified .csproj as TEXT
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build">
<Sdk Name="MSBuild.Sdk.SqlProj" Version="2.7.2" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<SqlServerVersion>Sql150</SqlServerVersion>
<SuppressTSqlWarnings>71558,71502</SuppressTSqlWarnings>
<TargetName>CAPSHistoryDatabase</TargetName>
<RunScriptsFromReferences>True</RunScriptsFromReferences>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SqlConvert|AnyCPU' ">
<OutputPath>bin\SqlConvert\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Compilation properties -->
<PropertyGroup>
<GenerateCreateScript>True</GenerateCreateScript>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
</PropertyGroup>
<!-- Pre- and Post-Deployment scripts and tables -->
<ItemGroup>
<Build Include="dbo\Tables\CapsRunStatus.sql" />
<Build Include="dbo\Tables\CapsHold.sql" />
<Build Include="dbo\Tables\CapsCCTXRef.sql" />
<Build Include="dbo\Tables\CapsSkipReason.sql" />
<Build Include="dbo\Tables\Global.sql" />
<Build Include="dbo\Tables\CapsRun.sql" />
<Build Include="dbo\Tables\DbPurgeTables.sql" />
<None Include="shared.publish.xml" />
<None Include="SchemaComparisons\SchemaComparison.scmp" />
</ItemGroup>
<ItemGroup>
<PostDeploy Include="Scripts\Script.PostDeployment.sql" />
<PreDeploy Include="Scripts\Script.PreDeployment.sql" />
</ItemGroup>
<ItemGroup>
<None Include="Scripts\Post-Deployment\2427.0-PostDeployment.sql" />
<None Include="Scripts\Pre-Deployment\2427.0-PreDeployment.sql" />
</ItemGroup>
</Project>
I think you need to exclude the Pre/PostDeploy scripts as well:
<ItemGroup>
<None Include="Scripts\Script.PostDeployment.sql" />
<None Include="Scripts\Script.PreDeployment.sql" />
<None Include="Scripts\Post-Deployment\2427.0-PostDeployment.sql" />
<None Include="Scripts\Pre-Deployment\2427.0-PreDeployment.sql" />
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build">
<Sdk Name="MSBuild.Sdk.SqlProj" Version="2.7.2" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<SqlServerVersion>Sql150</SqlServerVersion>
<SuppressTSqlWarnings>71558,71502</SuppressTSqlWarnings>
<TargetName>CAPSHistoryDatabase</TargetName>
<RunScriptsFromReferences>True</RunScriptsFromReferences>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SqlConvert|AnyCPU' ">
<OutputPath>bin\SqlConvert\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Compilation properties -->
<PropertyGroup>
<GenerateCreateScript>True</GenerateCreateScript>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
</PropertyGroup>
<!-- Pre- and Post-Deployment scripts and tables -->
<ItemGroup>
<Build Include="dbo\Tables\CapsRunStatus.sql" />
<Build Include="dbo\Tables\CapsHold.sql" />
<Build Include="dbo\Tables\CapsCCTXRef.sql" />
<Build Include="dbo\Tables\CapsSkipReason.sql" />
<Build Include="dbo\Tables\Global.sql" />
<Build Include="dbo\Tables\CapsRun.sql" />
<Build Include="dbo\Tables\DbPurgeTables.sql" />
<None Include="shared.publish.xml" />
<None Include="SchemaComparisons\SchemaComparison.scmp" />
</ItemGroup>
<ItemGroup>
<None Include="Scripts\Script.PostDeployment.sql" />
<None Include="Scripts\Script.PreDeployment.sql" />
<None Include="Scripts\Post-Deployment\2427.0-PostDeployment.sql" />
<None Include="Scripts\Pre-Deployment\2427.0-PreDeployment.sql" />
</ItemGroup>
</Project>
Error i see
Business git:(migrate_to_dacpac) ✗ dotnet build src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj
MSBuild version 17.8.5+b5265ef37 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
Using target framework net8.0 to run DacpacTool
Using package name CAPSHistoryDatabase and version 1.0.0
Using SQL Server version Sql150
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/dbo/Tables/CapsCCTXRef.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/dbo/Tables/CapsHold.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/dbo/Tables/CapsRun.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/dbo/Tables/CapsRunStatus.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/dbo/Tables/CapsSkipReason.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/dbo/Tables/DbPurgeTables.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/dbo/Tables/Global.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/Scripts/Post-Deployment/2427.0-PostDeployment.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/Scripts/Pre-Deployment/2427.0-PreDeployment.sql to the model
Adding /Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/Scripts/Script.PostDeployment.sql to the model
Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> Microsoft.SqlServer.Dac.Model.DacModelException: Add or update objects failed due to the following errors:
EXEC : error SQL46010: Incorrect syntax near ' Post-Deployment'. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
EXEC : error SQL46010: Incorrect syntax near TRY. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
EXEC : error SQL46005: Expected TRY but encountered CATCH instead. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
EXEC : error SQL46010: Incorrect syntax near BEGIN. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
EXEC : error SQL46029: Unexpected end of file occurred. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
at Microsoft.SqlServer.Dac.Model.SqlSchemaModelObjectService.ThrowIfModelErrorsExist(String errorMessage)
at Microsoft.SqlServer.Dac.Model.SqlSchemaModelObjectService.DoAddOrUpdateObjects(String inputScript, String sourceName, TSqlObjectOptions options)
at Microsoft.SqlServer.Dac.Model.SqlSchemaModelObjectService.AddOrUpdateObjects(String inputScript, String sourceName, TSqlObjectOptions options)
at Microsoft.SqlServer.Dac.Model.TSqlModel.AddOrUpdateObjects(String inputScript, String sourceName, TSqlObjectOptions options)
at MSBuild.Sdk.SqlProj.DacpacTool.PackageBuilder.AddInputFile(FileInfo inputFile) in /home/runner/work/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj/src/DacpacTool/PackageBuilder.cs:line 80
at MSBuild.Sdk.SqlProj.DacpacTool.Program.BuildDacpac(BuildOptions options) in /home/runner/work/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj/src/DacpacTool/Program.cs:line 145
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Parsing.ParseResultExtensions.InvokeAsync(ParseResult parseResult, IConsole console)
at MSBuild.Sdk.SqlProj.DacpacTool.Program.Main(String[] args) in /home/runner/work/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj/src/DacpacTool/Program.cs:line 80
at MSBuild.Sdk.SqlProj.DacpacTool.Program.<Main>(String[] args)
/var/folders/bt/667kwdxd56ngvh9zzmcnz2fdg8rryb/T/MSBuildTempbheemvennapureddy/tmp4927fccd72a949db83f41d6ff657fc1f.exec.cmd: line 2: 93940 Abort trap: 6 dotnet "/Users/bheemvennapureddy/.nuget/packages/msbuild.sdk.sqlproj/2.7.2/Sdk/../tools/net8.0/DacpacTool.dll" build -o "obj/Debug/netstandard2.0/CAPSHistoryDatabase.dacpac" -n "CAPSHistoryDatabase" -v "1.0.0" -sv Sql150 -i "obj/Debug/netstandard2.0/CAPSHistoryDatabase.InputFiles.txt" -dp IncludeCompositeObjects=True -spw "71558,71502" --generatecreatescript
/Users/bheemvennapureddy/.nuget/packages/msbuild.sdk.sqlproj/2.7.2/Sdk/Sdk.targets(244,5): error MSB3073: The command "dotnet "/Users/bheemvennapureddy/.nuget/packages/msbuild.sdk.sqlproj/2.7.2/Sdk/../tools/net8.0/DacpacTool.dll" build -o "obj/Debug/netstandard2.0/CAPSHistoryDatabase.dacpac" -n "CAPSHistoryDatabase" -v "1.0.0" -sv Sql150 -i "obj/Debug/netstandard2.0/CAPSHistoryDatabase.InputFiles.txt" -dp IncludeCompositeObjects=True -spw "71558,71502" --generatecreatescript " exited with code 134. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
Build FAILED.
EXEC : error SQL46010: Incorrect syntax near ' Post-Deployment'. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
EXEC : error SQL46010: Incorrect syntax near TRY. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
EXEC : error SQL46005: Expected TRY but encountered CATCH instead. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
EXEC : error SQL46010: Incorrect syntax near BEGIN. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
EXEC : error SQL46029: Unexpected end of file occurred. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
/Users/bheemvennapureddy/.nuget/packages/msbuild.sdk.sqlproj/2.7.2/Sdk/Sdk.targets(244,5): error MSB3073: The command "dotnet "/Users/bheemvennapureddy/.nuget/packages/msbuild.sdk.sqlproj/2.7.2/Sdk/../tools/net8.0/DacpacTool.dll" build -o "obj/Debug/netstandard2.0/CAPSHistoryDatabase.dacpac" -n "CAPSHistoryDatabase" -v "1.0.0" -sv Sql150 -i "obj/Debug/netstandard2.0/CAPSHistoryDatabase.InputFiles.txt" -dp IncludeCompositeObjects=True -spw "71558,71502" --generatecreatescript " exited with code 134. [/Users/bheemvennapureddy/github/Business/src/CAPSHistoryDatabase/CAPSHistoryDatabase.sqlproj]
0 Warning(s)
6 Error(s)
Time Elapsed 00:00:05.85
➜ Business git:(migrate_to_dacpac) ✗
Why did you remove this?
<ItemGroup>
<PostDeploy Include="Scripts\Script.PostDeployment.sql" />
<PreDeploy Include="Scripts\Script.PreDeployment.sql" />
</ItemGroup>
In any case, please share a repro project, so I can help you. You can email me ejlskov at hotmail dot com
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build">
<Sdk Name="MSBuild.Sdk.SqlProj" Version="2.7.2" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<SqlServerVersion>Sql150</SqlServerVersion>
<SuppressTSqlWarnings>71558,71502</SuppressTSqlWarnings>
<TargetName>CAPSHistoryDatabase</TargetName>
<RunScriptsFromReferences>True</RunScriptsFromReferences>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SqlConvert|AnyCPU' ">
<OutputPath>bin\SqlConvert\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Compilation properties -->
<PropertyGroup>
<GenerateCreateScript>True</GenerateCreateScript>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
</PropertyGroup>
<!-- Pre- and Post-Deployment scripts and tables -->
<ItemGroup>
<Build Include="dbo\Tables\CapsRunStatus.sql" />
<Build Include="dbo\Tables\CapsHold.sql" />
<Build Include="dbo\Tables\CapsCCTXRef.sql" />
<Build Include="dbo\Tables\CapsSkipReason.sql" />
<Build Include="dbo\Tables\Global.sql" />
<Build Include="dbo\Tables\CapsRun.sql" />
<Build Include="dbo\Tables\DbPurgeTables.sql" />
<None Include="shared.publish.xml" />
<None Include="SchemaComparisons\SchemaComparison.scmp" />
</ItemGroup>
<ItemGroup>
<PostDeploy Include="Scripts\Script.PostDeployment.sql" />
<PreDeploy Include="Scripts\Script.PreDeployment.sql" />
</ItemGroup>
<ItemGroup>
<None Include="Scripts\Script.PostDeployment.sql" />
<None Include="Scripts\Script.PreDeployment.sql" />
<None Include="Scripts\Post-Deployment\2427.0-PostDeployment.sql" />
<None Include="Scripts\Pre-Deployment\2427.0-PreDeployment.sql" />
</ItemGroup>
</Project>
Even if i include I see the same error
I need a full repro project in order to help you.
Looks like it is actually:
<ItemGroup>
<Content Remove="Script.sql" />
</ItemGroup>
<ItemGroup>
<None Update="Script.sql" />
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build">
<Sdk Name="MSBuild.Sdk.SqlProj" Version="2.7.2" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<SqlServerVersion>Sql150</SqlServerVersion>
<SuppressTSqlWarnings>71558,71502</SuppressTSqlWarnings>
<TargetName>CAPSHistoryDatabase</TargetName>
<RunScriptsFromReferences>True</RunScriptsFromReferences>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SqlConvert|AnyCPU' ">
<OutputPath>bin\SqlConvert\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Compilation properties -->
<PropertyGroup>
<GenerateCreateScript>True</GenerateCreateScript>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
</PropertyGroup>
<!-- Pre- and Post-Deployment scripts and tables -->
<ItemGroup>
<Build Include="dbo\Tables\CapsRunStatus.sql" />
<Build Include="dbo\Tables\CapsHold.sql" />
<Build Include="dbo\Tables\CapsCCTXRef.sql" />
<Build Include="dbo\Tables\CapsSkipReason.sql" />
<Build Include="dbo\Tables\Global.sql" />
<Build Include="dbo\Tables\CapsRun.sql" />
<Build Include="dbo\Tables\DbPurgeTables.sql" />
<None Include="shared.publish.xml" />
<None Include="SchemaComparisons\SchemaComparison.scmp" />
</ItemGroup>
<ItemGroup>
<PostDeploy Include="Scripts\Script.PostDeployment.sql" />
<PreDeploy Include="Scripts\Script.PreDeployment.sql" />
</ItemGroup>
<ItemGroup>
<Content Remove="Scripts\Script.PostDeployment.sql" />
<Content Remove="Scripts\Script.PreDeployment.sql" />
<Content Remove="Scripts\Post-Deployment\2427.0-PostDeployment.sql" />
<Content Remove="Scripts\Pre-Deployment\2427.0-PreDeployment.sql" />
</ItemGroup>
<ItemGroup>
<None Update="Scripts\Script.PostDeployment.sql" />
<None Update="Scripts\Script.PreDeployment.sql" />
<None Update="Scripts\Post-Deployment\2427.0-PostDeployment.sql" />
<None Update="Scripts\Pre-Deployment\2427.0-PreDeployment.sql" />
</ItemGroup>
</Project>
if this is what is expected that worked then
Is that really a None Update over None Include ?
None Update
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build">
<Sdk Name="MSBuild.Sdk.SqlProj" Version="2.7.2" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<SqlServerVersion>Sql150</SqlServerVersion>
<SuppressTSqlWarnings>71558,71502</SuppressTSqlWarnings>
<TargetName>CAPSHistoryDatabase</TargetName>
<RunScriptsFromReferences>True</RunScriptsFromReferences>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SqlConvert|AnyCPU' ">
<OutputPath>bin\SqlConvert\</OutputPath>
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Compilation properties -->
<PropertyGroup>
<GenerateCreateScript>True</GenerateCreateScript>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
</PropertyGroup>
<!-- Pre- and Post-Deployment scripts and tables -->
<ItemGroup>
<Build Include="dbo\Tables\CapsRunStatus.sql" />
<Build Include="dbo\Tables\CapsHold.sql" />
<Build Include="dbo\Tables\CapsCCTXRef.sql" />
<Build Include="dbo\Tables\CapsSkipReason.sql" />
<Build Include="dbo\Tables\Global.sql" />
<Build Include="dbo\Tables\CapsRun.sql" />
<Build Include="dbo\Tables\DbPurgeTables.sql" />
<None Include="shared.publish.xml" />
<None Include="SchemaComparisons\SchemaComparison.scmp" />
</ItemGroup>
<ItemGroup>
<PostDeploy Include="Scripts\Script.PostDeployment.sql" />
<PreDeploy Include="Scripts\Script.PreDeployment.sql" />
</ItemGroup>
<ItemGroup>
<Content Remove="Scripts\Script.PostDeployment.sql" />
<Content Remove="Scripts\Script.PreDeployment.sql" />
</ItemGroup>
</Project>
just doing the content remove from pre and post deploy worked - need to test the dapac
Here is the reference for the project file
Exception seen :