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

Projects don't rebuild after committing #322

Closed
ansteele opened this issue Oct 20, 2023 · 2 comments · Fixed by #343
Closed

Projects don't rebuild after committing #322

ansteele opened this issue Oct 20, 2023 · 2 comments · Fixed by #343

Comments

@ansteele
Copy link

Describe the Bug

Projects don't rebuild following a commit to the current git branch.

Steps to Reproduce

  1. Build a project (managed under git)
  2. Make a change unrelated to that project (not a source file within that project)
  3. Commit the change to the current git branch
  4. Hit build on the project

Using this as our property sheet:

<Target Name="PopulateInfo" BeforeTargets="CoreCompile;GetAssemblyVersion;GenerateNuspec;GetPackageContents">
    <PropertyGroup>
	<Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)</Version>
	<PackageVersion>$(Version)</PackageVersion>
	<FileVersion>$(Version)</FileVersion>
	<RepositoryCommit>$(GitCommit)</RepositoryCommit>
    </PropertyGroup>

    <Error Text="Failed to determine product version" Condition="'$(GitCommit)' == ''" />
</Target>

Expected Behavior

The project rebuilds with a new version (based on git status).

Exception with Stack Trace

No exception but the project is marked as up-to-date and doesn't rebuild.

Version Info

GitInfo-3.3.1

Additional Info

I found #186 as a similar issue but that seems to deal with switching HEAD rather than moving HEAD forward by committing. (The .git\HEAD file only changes when the branch name/checked out commit changes)

I've got a workaround by adding the git log for HEAD to the MSBuild up-to-date inputs as that file seems to reliably change on commit.

<ItemGroup>
    <UpToDateCheckInput Include="$(SolutionDir).git\logs\HEAD" />
</ItemGroup>

Thanks :)

@ansteele ansteele added the bug label Oct 20, 2023
@kzu
Copy link
Member

kzu commented Feb 15, 2024

Would you like to submit a PR so it's properly attributed to you? 🙏

@kzu
Copy link
Member

kzu commented May 13, 2024

The workaround only works if the solution is at the root of a repository. The proper fix would be to leverage the $(GitRoot) we already determine via targets, and expose that to the incremental check. See https://github.com/dotnet/project-system/blob/main/docs/up-to-date-check.md for more on how it could be implemented.

@kzu kzu closed this as completed in #343 May 30, 2024
@devlooped devlooped locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants