gitvisual-studio-2022sql-server-data-tools

Git not picking up change to database project's properties in Visual Studio 2022


I am changing a setting in visual studio project but git does not seem to be picking it up?

I am right clicking my project (database project) in visual studio, clicked properties and changing a option in the Debug Menu (One highlighted in screenshot).

I rebuild the solution so am expecting git to pick up that something has changed but it does not. I wanted to check this change into version control as we have having release issues.

I would have thought it would be a gitignore issue but I do not ignore the .sqlproj file and I would expect this is the file that would change?

Would anyone know what file would be changed?

Property being changed

I tried including various files into source control so they were not ignored but cannot locate the file that would store this setting


Solution

  • That setting isn't stored in the database project itself (.sqlproj), but in the associated per-user-settings file (.sqlproj.user):

    <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <StartupScript>(Blank)</StartupScript>
        <StartAction>StartNone</StartAction>
        <BlockOnPossibleDataLoss>True</BlockOnPossibleDataLoss>
      </PropertyGroup>
    </Project>
    

    The *.user files are excluded by the default Visual Studio .gitIgnore file.

    If you want this setting to be stored in the git repository, you'll need to manually add it to the .sqlproj file by editing the project file's xml directly and adding:

        <BlockOnPossibleDataLoss>True</BlockOnPossibleDataLoss>
    

    To any of the default property groups or to a new one.

    To do so, unload the project:

    Unload project in the context menu of the solution explorer

    Then edit the project (if the XML view doesn't open automatically): Edit the project from the context menu in the solution explorer

    Add the property to the project file:

    <?xml version="1.0" encoding="utf-8"?>
    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
      <PropertyGroup>
        <BlockOnPossibleDataLoss>True</BlockOnPossibleDataLoss>
      </PropertyGroup>
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <Name>Database1</Name>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectVersion>4.1</ProjectVersion>
        <ProjectGuid>{9b8b7b42-6d5c-4711-b7fa-567d2c0c6642}</ProjectGuid>
        <DSP>Microsoft.Data.Tools.Schema.Sql
    

    Reload the project:

    Reload the project from the solution explorer

    The setting has now been lifted from the user settings to the project file and the change should show up in your git changes, ready to be committed:

    enter image description here