Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental building #448

Open
benjamin-hodgson opened this issue May 17, 2024 · 2 comments
Open

Incremental building #448

benjamin-hodgson opened this issue May 17, 2024 · 2 comments
Labels
area: build sdk Related to Microsoft.Build.Sql SDK enhancement New feature or request

Comments

@benjamin-hodgson
Copy link

benjamin-hodgson commented May 17, 2024

If I've built my sqlproj already, and none of the .sql files in the project have changed, the output dacpac should not be rebuilt the next time I run dotnet build.

From what I can tell, this seems to be something to do with the fact that Microsoft.Build.Sql inherits the default C# targets and produces a dll by default. The log says: Input file "D:\test\MyDb\obj\Debug\MyDb.dll" is newer than output file "D:\test\MyDb\bin\Debug\MyDb.dacpac". and MyDb.dll appears to be produced by CoreCompile running right before SqlBuild.

Perhaps Microsoft.Build.Sql should do something similar to what Microsoft.Build.NoTargets does to suppress the production of an assembly?

@benjamin-hodgson benjamin-hodgson changed the title Incremental Incremental building May 17, 2024
@benjamin-hodgson
Copy link
Author

I've managed to work around it, for now, by manually importing the SDK and pasting some code from NoTargets:

<Project>

    <PropertyGroup>
        <!-- https://github.com/microsoft/MSBuildSdks/blob/32403937dc2bb90f74c2156b9e140538b3f25d51/src/NoTargets/Sdk/Sdk.props#L49 -->
        <!-- Don't log the high priority message mentioning this project's name (or copy the product we didn't build). -->
        <SkipCopyBuildProduct>true</SkipCopyBuildProduct>
    </PropertyGroup>

    <Import Project="Sdk.props" Sdk="Microsoft.Build.Sql" Version="0.1.15-preview" />

    <PropertyGroup>
        <Name>MyDb</Name>
        <DSP>Microsoft.Data.Tools.Schema.Sql.Sql160DatabaseSchemaProvider</DSP>
        <ModelCollation>1033, CI</ModelCollation>
    </PropertyGroup>

    <Import Project="Sdk.targets" Sdk="Microsoft.Build.Sql" Version="0.1.15-preview" />

    <!-- https://github.com/microsoft/MSBuildSdks/blob/32403937dc2bb90f74c2156b9e140538b3f25d51/src/NoTargets/Sdk/Sdk.targets#L34 -->
    <PropertyGroup>
        <!-- This property must be overridden to remove a few targets that compile assemblies -->
        <CoreBuildDependsOn>
            BuildOnlySettings;
            PrepareForBuild;
            PreBuildEvent;
            ResolveReferences;
            Compile;
            GetTargetPath;
            PrepareForRun;
            IncrementalClean;
            PostBuildEvent
        </CoreBuildDependsOn>

        <!-- Disable symbol generation -->
        <DebugType>None</DebugType>
        <DebugSymbols>false</DebugSymbols>

        <!-- Don't emit a reference assembly -->
        <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
    </PropertyGroup>

    <!-- Clear output group items which are read by the IDE and NuGet. -->
    <ItemGroup>
        <BuiltProjectOutputGroupKeyOutput Remove="@(BuiltProjectOutputGroupKeyOutput)" />
        <DebugSymbolsProjectOutputGroupOutput Remove="@(DebugSymbolsProjectOutputGroupOutput)" />
        <IntermediateAssembly Remove="@(IntermediateAssembly)" />
        <IntermediateRefAssembly Remove="@(IntermediateRefAssembly)" />
        <Reference Remove="mscorlib" />
    </ItemGroup>

    <!-- https://github.com/microsoft/MSBuildSdks/blob/32403937dc2bb90f74c2156b9e140538b3f25d51/src/NoTargets/Sdk/Sdk.targets#L95 -->
    <!-- Override stock CoreCompile target to do nothing but keep extensibility points -->
    <Target
        Name="CoreCompile"
        DependsOnTargets="$(CoreCompileDependsOn)">

        <CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''" />

    </Target>

</Project>

Would you consider moving this code (or something similar) into the SDK?

@zijchen zijchen added enhancement New feature or request area: build sdk Related to Microsoft.Build.Sql SDK labels May 22, 2024
@zijchen
Copy link
Member

zijchen commented May 22, 2024

@Ri7Sh In #443 you have CoreCompile overridden. Do you think the proposed changes will work with SSDT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build sdk Related to Microsoft.Build.Sql SDK enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants