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

.Net 8 Build fails when inside a particular git repository #1097

Open
quixoticaxis opened this issue Sep 12, 2023 · 10 comments
Open

.Net 8 Build fails when inside a particular git repository #1097

quixoticaxis opened this issue Sep 12, 2023 · 10 comments

Comments

@quixoticaxis
Copy link

Description

When I try to build a new console project inside a particular git repository the build fails:

dotnet build
MSBuild version 17.8.0-preview-23367-03+0ff2a83e9 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
/usr/local/dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64/sdk/8.0.100-preview.7.23376.3/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(314,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [/home/user/folder/folder/repo/000000-папка-C#/Project/Project.csproj]
/usr/local/dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64/sdk/8.0.100-preview.7.23376.3/Sdks/Microsoft.Build.Tasks.Git/build/Microsoft.Build.Tasks.Git.targets(25,5): error : Error reading git repository information: Unsupported repository extension 'objectformat'. Only noop, preciousObjects, partialclone, worktreeConfig are supported. [/home/user/folder/folder/repo/000000-папка-C#/Project/Project.csproj]

Build FAILED.

/usr/local/dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64/sdk/8.0.100-preview.7.23376.3/Sdks/Microsoft.Build.Tasks.Git/build/Microsoft.Build.Tasks.Git.targets(25,5): error : Error reading git repository information: Unsupported repository extension 'objectformat'. Only noop, preciousObjects, partialclone, worktreeConfig are supported. [/home/user/folder/folder/repo/000000-папка-C#/Project/Project.csproj]
0 Warning(s)
1 Error(s)

When the same project is moved out of git repository, it builds fine.

Reproduction Steps

I cannot reproduce the bug inside freshly initialized git repositories.

Expected behavior

The build cares not about whether the project is under the source control and succeeds.

Actual behavior

The build fails with cryptic error:

dotnet build
MSBuild version 17.8.0-preview-23367-03+0ff2a83e9 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
/usr/local/dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64/sdk/8.0.100-preview.7.23376.3/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(314,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [/home/user/folder/folder/repo/000000-папка-C#/Project/Project.csproj]
/usr/local/dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64/sdk/8.0.100-preview.7.23376.3/Sdks/Microsoft.Build.Tasks.Git/build/Microsoft.Build.Tasks.Git.targets(25,5): error : Error reading git repository information: Unsupported repository extension 'objectformat'. Only noop, preciousObjects, partialclone, worktreeConfig are supported. [/home/user/folder/folder/repo/000000-папка-C#/Project/Project.csproj]

Build FAILED.

/usr/local/dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64/sdk/8.0.100-preview.7.23376.3/Sdks/Microsoft.Build.Tasks.Git/build/Microsoft.Build.Tasks.Git.targets(25,5): error : Error reading git repository information: Unsupported repository extension 'objectformat'. Only noop, preciousObjects, partialclone, worktreeConfig are supported. [/home/user/folder/folder/repo/000000-папка-C#/Project/Project.csproj]
0 Warning(s)
1 Error(s)

Regression?

Probably not, never experienced it with any version of .Net (or .Net Framework).

Known Workarounds

It is possible to work with the project out of source control and constantly moving it in and out of repository, but that's a hustle.

Configuration

dotnet: dotnet --version -> 8.0.100-preview.7.23376.3
OS: lsb_release -a -> Ubuntu 22.04.3 LTS (Actually, Kubuntu).
Architecture: x64.
I don't know whether it is specific to configuration.
I do not use Blazor.

Other information

No response

@vcsjones
Copy link
Member

Did you enable experimental SHA-256 support in your git repository? i.e. when you created your git repository, did you do git init --object-format sha256?

If you aren't sure, you can do git config extensions.objectformat. If it prints "sha256" then you are using the SHA256 extension.

I would guess that Microsoft.Build.Tasks.Git.targets does not support SHA256 Git repositories, which makes sense given that it is experimental.

You will need to re-initialize the Git repository without the objectformat extension to change back to SHA1 - you can't change it after the repository has been initialized.

I can reproduce this with a SHA256 repository:

~/Projects/sha256-repo                                                                                                            ❮ x64 
❯ dotnet build
MSBuild version 17.8.0-preview-23367-03+0ff2a83e9 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
/usr/local/share/dotnet/sdk/8.0.100-preview.7.23376.3/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(314,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [/Users/vcsjones/Projects/sha256-repo/sha256-repo.csproj]
/usr/local/share/dotnet/sdk/8.0.100-preview.7.23376.3/Sdks/Microsoft.Build.Tasks.Git/build/Microsoft.Build.Tasks.Git.targets(25,5): error : Error reading git repository information: Unsupported repository extension 'objectformat'. Only noop, preciousObjects, partialclone, worktreeConfig are supported. [/Users/vcsjones/Projects/sha256-repo/sha256-repo.csproj]

@jkotas jkotas transferred this issue from dotnet/runtime Sep 12, 2023
@quixoticaxis
Copy link
Author

quixoticaxis commented Sep 12, 2023

@vcsjones , thank you. Yes, I use SHA-256.
Is it possible to somehow turn off the integration?

@KalleOlaviNiemitalo
Copy link

There's a condition on $(SuppressImplicitGitSourceLink) here: https://github.com/dotnet/sdk/blob/b9a275259a7a2e993ba6a21676a2679a7e128814/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CrossTargeting.targets#L15

@baronfel
Copy link
Member

baronfel commented Sep 12, 2023

More broadly you can disable SourceLink for a given project/repository by setting EnableSourceLink to false. See below, this isn't enough and other properties are needed.

@baronfel
Copy link
Member

Hey @tmat should this get moved to dotnet/sourcelink and triaged?

@baronfel
Copy link
Member

(also we're going to start tagging sourcelink-related issues with the Area-SourceLink label - can your team do periodic triage of these?)

@vcsjones
Copy link
Member

More broadly you can disable SourceLink for a given project/repository by setting EnableSourceLink to false.

This does not work: <EnableSourceLink>false</EnableSourceLink>

This does: <SuppressImplicitGitSourceLink>true</SuppressImplicitGitSourceLink>

@tmat
Copy link
Member

tmat commented Sep 12, 2023

Yes, please move the issue to dotnet/sourcelink

@tmat
Copy link
Member

tmat commented Sep 12, 2023

EnableSourceLink wouldn't disable all git information reading as Source Link file generator is not the only build task that reads the git data. Setting EnableSourceControlManagerQueries to false should do.

SuppressImplicitGitSourceLink also works since it removes all implicitly added Source Link packages.

@baronfel
Copy link
Member

@tmat I can't transfer (perhaps due to permissions?) - can you transfer from this repo to dotnet/sourcelink?

@tmat tmat transferred this issue from dotnet/sdk Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants