Skip to content

Smdn.MSBuild.ProjectAssets.Common version 1.7.3

Latest

Choose a tag to compare

@smdn smdn released this 26 Nov 13:10
Immutable release. Only release title and notes can be modified.
f5cdca6

Released package

Release notes

The full release notes are available at gist.

Change log

Change log in this release:

Full changes

Full changes in this release:
diff --git a/src/Smdn.MSBuild.ProjectAssets.Common/Smdn.MSBuild.ProjectAssets.Common.csproj b/src/Smdn.MSBuild.ProjectAssets.Common/Smdn.MSBuild.ProjectAssets.Common.csproj
index 9084354..3d1679d 100644
--- a/src/Smdn.MSBuild.ProjectAssets.Common/Smdn.MSBuild.ProjectAssets.Common.csproj
+++ b/src/Smdn.MSBuild.ProjectAssets.Common/Smdn.MSBuild.ProjectAssets.Common.csproj
@@ -6,7 +6,7 @@ SPDX-License-Identifier: MIT
   <Import Project="$(MSBuildThisFileDirectory)..\..\eng\ProjectSettings.NoAssemblies.props" />
 
   <PropertyGroup>
-    <VersionPrefix>1.7.2</VersionPrefix>
+    <VersionPrefix>1.7.3</VersionPrefix>
     <VersionSuffix></VersionSuffix>
     <DevelopmentDependency>true</DevelopmentDependency>
     <PackageType>Dependency;MSBuildSdk</PackageType>
diff --git a/src/Smdn.MSBuild.ProjectAssets.Common/project/targets/GenerateNuspecDifference.targets b/src/Smdn.MSBuild.ProjectAssets.Common/project/targets/GenerateNuspecDifference.targets
index 3a0c60a..824c43e 100644
--- a/src/Smdn.MSBuild.ProjectAssets.Common/project/targets/GenerateNuspecDifference.targets
+++ b/src/Smdn.MSBuild.ProjectAssets.Common/project/targets/GenerateNuspecDifference.targets
@@ -1,4 +1,4 @@
-<!--
+<!--
 SPDX-FileCopyrightText: 2023 smdn <smdn@smdn.jp>
 SPDX-License-Identifier: MIT
 -->
@@ -37,6 +37,7 @@ SPDX-License-Identifier: MIT
 
     <Error
       Text=".nuspec file not generated or not found"
+      File="$(MSBuildProjectFile)"
       Condition="!Exists($(_GeneratedNuspecFilePath))"
     />
 
diff --git a/src/Smdn.MSBuild.ProjectAssets.Common/project/targets/GetRepositoryProperties.targets b/src/Smdn.MSBuild.ProjectAssets.Common/project/targets/GetRepositoryProperties.targets
index c89daa0..83f9980 100644
--- a/src/Smdn.MSBuild.ProjectAssets.Common/project/targets/GetRepositoryProperties.targets
+++ b/src/Smdn.MSBuild.ProjectAssets.Common/project/targets/GetRepositoryProperties.targets
@@ -1,9 +1,13 @@
-<!--
+<!--
 SPDX-FileCopyrightText: 2021 smdn <smdn@smdn.jp>
 SPDX-License-Identifier: MIT
 -->
 <Project>
   <Target Name="GetRepositoryProperties">
+    <PropertyGroup>
+      <_IsInsideOfRepositoryTree>false</_IsInsideOfRepositoryTree>
+    </PropertyGroup>
+
     <!-- If $(RepositoryType) is not explicitly specified, it is assumed to be 'git'. -->
     <CallTarget
       Targets="GetRepositoryProperties_Git"
@@ -20,9 +24,24 @@ SPDX-License-Identifier: MIT
     </PropertyGroup>
 
     <Exec
-      Command="$(GitCommandLineInterfacePath) branch --show-current"
+      Command="$(GitCommandLineInterfacePath) rev-parse --git-dir"
       Condition=" '$(GitCommandLineInterfacePath)' != '' and '$(RepositoryBranch)' == '' "
       ConsoleToMSBuild="true"
+      IgnoreExitCode="true"
+      StandardOutputImportance="Low"
+      StandardErrorImportance="Low"
+    >
+      <Output TaskParameter="ExitCode" PropertyName="_GitRevParseGitDirExitCode" />
+    </Exec>
+
+    <PropertyGroup>
+      <_IsInsideOfRepositoryTree Condition="'$(_GitRevParseGitDirExitCode)' == '0'">true</_IsInsideOfRepositoryTree>
+    </PropertyGroup>
+
+    <Exec
+      Command="$(GitCommandLineInterfacePath) branch --show-current"
+      Condition=" '$(_IsInsideOfRepositoryTree)' == 'true' and '$(GitCommandLineInterfacePath)' != '' and '$(RepositoryBranch)' == '' "
+      ConsoleToMSBuild="true"
       EchoOff="true"
       StandardOutputImportance="Low"
     >
@@ -31,7 +50,7 @@ SPDX-License-Identifier: MIT
 
     <Exec
       Command="$(GitCommandLineInterfacePath) rev-parse HEAD"
-      Condition=" '$(GitCommandLineInterfacePath)' != '' and '$(RepositoryCommit)' == '' "
+      Condition=" '$(_IsInsideOfRepositoryTree)' == 'true' and '$(GitCommandLineInterfacePath)' != '' and '$(RepositoryCommit)' == '' "
       ConsoleToMSBuild="true"
       EchoOff="true"
       StandardOutputImportance="Low"
@@ -40,7 +59,19 @@ SPDX-License-Identifier: MIT
     </Exec>
   </Target>
 
-  <Target Name="GetRepositoryProperties_VersionOrRepositoryTypeNotSupported" Condition="('$(RepositoryBranch)' == '') and ('$(RepositoryCommit)' == '')">
-    <Error Text="could not get repository properties (type: $(RepositoryType))" />
+  <Target
+    Name="GetRepositoryProperties_VersionOrRepositoryTypeNotSupported"
+    Condition="('$(RepositoryBranch)' == '') and ('$(RepositoryCommit)' == '')"
+  >
+    <Error
+      Text="Could not get repository properties (type: $(RepositoryType))"
+      File="$(MSBuildProjectFile)"
+      Condition="'$(_IsInsideOfRepositoryTree)' == 'true'"
+    />
+    <Warning
+      Text="Could not get repository properties; project may not be in the repository tree. (type: $(RepositoryType))"
+      File="$(MSBuildProjectFile)"
+      Condition="'$(_IsInsideOfRepositoryTree)' != 'true'"
+    />
   </Target>
 </Project>

Notes

What's Changed

Dependencies

  • Bump github/codeql-action/upload-sarif from 4.38.0 to 4.39.0 in the github-codeql-actions group by @dependabot[bot] in #7
  • Bump ossf/scorecard-action from 2.5.0 to 2.6.0 by @dependabot[bot] in #15

New Contributors

Full Changelog: releases/Smdn.MSBuild.ProjectAssets.Common-1.7.2...releases/Smdn.MSBuild.ProjectAssets.Common-1.7.3