diff --git a/docs/input/docs/usage/cli/arguments.md b/docs/input/docs/usage/cli/arguments.md
index a406ca76a0..c8a95ddbc5 100644
--- a/docs/input/docs/usage/cli/arguments.md
+++ b/docs/input/docs/usage/cli/arguments.md
@@ -66,7 +66,7 @@ GitVersion [path]
the git repo and update them
/updateprojectfiles
Will recursively search for all project files
- (.csproj/.vbproj/.fsproj) files in the git repo and update
+ (.csproj/.vbproj/.fsproj/.sqlproj) files in the git repo and update
them
Note: This is only compatible with the newer Sdk projects
/ensureassemblyinfo
diff --git a/src/GitVersion.Output.Tests/Output/ProjectFileUpdaterTests.cs b/src/GitVersion.Output.Tests/Output/ProjectFileUpdaterTests.cs
index 93bad568f5..aac07abadb 100644
--- a/src/GitVersion.Output.Tests/Output/ProjectFileUpdaterTests.cs
+++ b/src/GitVersion.Output.Tests/Output/ProjectFileUpdaterTests.cs
@@ -45,6 +45,7 @@ public void Setup()
[TestCase("Microsoft.NET.Sdk.WindowsDesktop")]
[TestCase("Microsoft.NET.Sdk.Razor")]
[TestCase("Microsoft.NET.Sdk.BlazorWebAssembly")]
+ [TestCase("Microsoft.Build.Sql")]
public void CanUpdateProjectFileWithSdkProjectFileXml(string sdk)
{
var xml = $"""
@@ -77,7 +78,7 @@ public void CannotUpdateProjectFileWithIncorrectProjectSdk(string xml)
logMessages.ShouldNotBeEmpty();
logMessages.Count.ShouldBe(1);
- logMessages[0].ShouldContain("Specified project file Sdk (SomeOtherProject.Sdk) is not supported, please ensure the project sdk starts with 'Microsoft.NET.Sdk'");
+ logMessages[0].ShouldContain("Specified project file Sdk (SomeOtherProject.Sdk) is not supported, please ensure the project sdk starts with 'Microsoft.NET.Sdk' or 'Microsoft.Build.Sql'");
}
[TestCase($"""
@@ -96,7 +97,7 @@ public void CannotUpdateProjectFileWithMissingProjectSdk(string xml)
logMessages.ShouldNotBeEmpty();
logMessages.Count.ShouldBe(1);
- logMessages[0].ShouldContain("Specified project file Sdk () is not supported, please ensure the project sdk starts with 'Microsoft.NET.Sdk'");
+ logMessages[0].ShouldContain("Specified project file Sdk () is not supported, please ensure the project sdk starts with 'Microsoft.NET.Sdk' or 'Microsoft.Build.Sql'");
}
[TestCase($"""
@@ -263,37 +264,36 @@ public void UpdateProjectXmlVersionElementWithMultipleVersionElementsLastOneIsMo
xmlRoot.ToString().ShouldBe(expectedXml.ToString());
}
- [TestCase("""
-
-
-
- Exe
- net8.0
-
-
- """)]
- public void UpdateProjectFileAddsVersionToFile(string xml)
+ [TestCase("Microsoft.NET.Sdk", "TestProject.csproj")]
+ [TestCase("Microsoft.Build.Sql", "TestProject.sqlproj")]
+ public void UpdateProjectFileAddsVersionToFile(string sdk, string projectName)
{
+ var xml = $"""
+
+
+ net8.0
+
+
+ """;
var workingDirectory = FileSystemHelper.Path.GetTempPath();
- var fileName = FileSystemHelper.Path.Combine(workingDirectory, "TestProject.csproj");
+ var fileName = FileSystemHelper.Path.Combine(workingDirectory, projectName);
VerifyAssemblyInfoFile(xml, fileName, AssemblyVersioningScheme.MajorMinorPatch, (fs, variables) =>
{
using var projFileUpdater = new ProjectFileUpdater(this.log, fs);
projFileUpdater.Execute(variables, new(workingDirectory, false, fileName));
- const string expectedXml = $"""
-
-
- Exe
- {TargetFramework}
- 2.3.1.0
- 2.3.1.0
- 2.3.1+3.Branch.foo.Sha.hash
- 2.3.1
-
-
- """;
+ var expectedXml = $"""
+
+
+ {TargetFramework}
+ 2.3.1.0
+ 2.3.1.0
+ 2.3.1+3.Branch.foo.Sha.hash
+ 2.3.1
+
+
+ """;
var transformedXml = fs.File.ReadAllText(fileName);
transformedXml.ShouldBe(XElement.Parse(expectedXml).ToString());
});
diff --git a/src/GitVersion.Output/AssemblyInfo/ProjectFileUpdater.cs b/src/GitVersion.Output/AssemblyInfo/ProjectFileUpdater.cs
index 797cbc12ba..4c362568fa 100644
--- a/src/GitVersion.Output/AssemblyInfo/ProjectFileUpdater.cs
+++ b/src/GitVersion.Output/AssemblyInfo/ProjectFileUpdater.cs
@@ -110,9 +110,10 @@ public bool CanUpdateProjectFile(XElement xmlRoot)
}
var sdkAttribute = xmlRoot.Attribute("Sdk");
- if (sdkAttribute?.Value.StartsWith("Microsoft.NET.Sdk") != true)
+ if (sdkAttribute?.Value.StartsWith("Microsoft.NET.Sdk") != true &&
+ sdkAttribute?.Value.StartsWith("Microsoft.Build.Sql") != true)
{
- log.Warning($"Specified project file Sdk ({sdkAttribute?.Value}) is not supported, please ensure the project sdk starts with 'Microsoft.NET.Sdk'");
+ log.Warning($"Specified project file Sdk ({sdkAttribute?.Value}) is not supported, please ensure the project sdk starts with 'Microsoft.NET.Sdk' or 'Microsoft.Build.Sql'");
return false;
}
@@ -217,6 +218,7 @@ private static bool IsSupportedProjectFile(string fileName)
return fileName.EndsWith(".csproj") ||
fileName.EndsWith(".fsproj") ||
- fileName.EndsWith(".vbproj");
+ fileName.EndsWith(".vbproj") ||
+ fileName.EndsWith(".sqlproj");
}
}