dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.17k stars 1.34k forks source link

build failed "Source control information is not available - the generated source link is empty" #5311

Open pelacables opened 4 years ago

pelacables commented 4 years ago

Hi,

I'm trying to build msbuild (msbuild-16.5.0.12403 and msbuild-16.4.0.56107) in Linux (SL7) with git 2.18.4 and dotNET-Core-SDK/3.1.3 but the build fails with errors like:

/home/user/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-19367-01/build/Microsoft.Build.Tasks.Git.targets(24,5): error : Unable to locate repository with working directory that contains directory '/dev/shm/msbuild/16.5.0/dummy-/msbuild-16.5.0.12403/src/Samples/Dependency'. [/dev/shm/msbuild/16.5.0/dummy-/msbuild-16.5.0.12403/src/Samples/Dependency/Dependency.csproj]

I get this same error for several directories.

Could someone give me an explanation on what the error means ? I'm sorry but I don't know what other information I can provide that can be helpful, I don't fully understand what's wrong.

Steps to reproduce

wget https://github.com/microsoft/msbuild/archive/v16.4.0.56107.tar.gz
tar -zxvf v16.4.0.56107.tar.gz
cd msbuild-16.4.0.56107
./build.sh

Expected behavior

Build success

Actual behavior

/home/x2phasr1/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-19367-01/build/Microsoft.Build.Tasks.Git.targets(24,5): error : Unable to locate repository with working directory tha
t contains directory '/dev/shm/msbuild-16.4.0.56107/src/Tasks.UnitTests'. [/dev/shm/msbuild-16.4.0.56107/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj]
/home/x2phasr1/.nuget/packages/microsoft.sourcelink.common/1.0.0-beta2-19367-01/build/Microsoft.SourceLink.Common.targets(50,5): error : Source control information is not available - the
generated source link is empty. [/dev/shm/msbuild-16.4.0.56107/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj]
    0 Warning(s)
    54 Error(s)

Time Elapsed 00:00:59.93
Build failed (exit code '1').
rainersigwald commented 4 years ago

The Arcade (https://github.com/dotnet/arcade) toolset that we use for some build infrastructure has an assumption that it will operate in a git repo, and doesn't like tarball-based builds. I think there's a property that can disable that functionality. Can you try passing /p:EnableSourceLink=false to the build? https://github.com/dotnet/sourcelink/blob/master/docs/README.md#enablesourcelink

pelacables commented 4 years ago

Thanks for the answer. unfortunately the error persists:

$ ./build.sh /p:EnableSourceLink=false
[...]
/home/user/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-19367-01/build/Microsoft.Build.Tasks.Git.targets(24,5): error : Unable to locate repository with working directory that contains directory '/dev/shm/msbuild-16.4.0.56107/src/Samples/XmlFileLogger'. [/dev/shm/msbuild-16.4.0.56107/src/Samples/XmlFileLogger/XmlFileLogger.csproj]
[...]
/home/user/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-19367-01/build/Microsoft.Build.Tasks.Git.targets(24,5): error : Unable to locate repository with working directory that contains directory '/dev/shm/msbuild-16.4.0.56107/src/Build.UnitTests'. [/dev/shm/msbuild-16.4.0.56107/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj]
    0 Warning(s)
    27 Error(s)

thanks

ahstram commented 4 years ago

I'm experiencing a similar error:

If I download the tarball via wget https://github.com/microsoft/msbuild/archive/v16.6.0.22303.tar.gz, I will run into the same 54 errors when running ./build.sh

[...]
    0 Warning(s)
    54 Error(s)
Time Elapsed 00:00:49.01
Build failed (exit code '1').

However, if I check out via:

$ git clone -b v16.6.0.22303 git@github.com:microsoft/msbuild.git msbuild-16.6.0.22303

I am able to run ./build.sh without issue on CentOS8.

lic0914 commented 3 years ago

OS Windows 10 Version 2004

I'm experiencing a similar error when I build coreclr used .\build.cmd -subset clr

I had only two Errors when I didn't add the parameter /p:EnableSourceLink=false

image

But I did add the parameter /p:EnableSourceLink=false ,I found the only one Error

image

For the Error ,I had no choice...

Maybe the issue should be appeared the dotnet/runtime issue

nathan-alden-hp commented 2 years ago

Related: https://github.com/dotnet/reproducible-builds/issues/13

mt-yu commented 2 years ago

I'm experiencing a similar error:

If I download the tarball via wget https://github.com/microsoft/msbuild/archive/v16.6.0.22303.tar.gz, I will run into the same 54 errors when running ./build.sh

[...]
    0 Warning(s)
    54 Error(s)
Time Elapsed 00:00:49.01
Build failed (exit code '1').

However, if I check out via:

$ git clone -b v16.6.0.22303 git@github.com:microsoft/msbuild.git msbuild-16.6.0.22303

I am able to run ./build.sh without issue on CentOS8.

@ahstram Thank you. This method works image

tig commented 2 years ago

I have this same issue with `Terminal.Gui.

https://github.com/migueldeicaza/gui.cs/

image
...
  <ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
  </ItemGroup>

  <PropertyGroup>
    <TargetFrameworks>net472;netstandard2.0;net6.0</TargetFrameworks>
    <RootNamespace>Terminal.Gui</RootNamespace>
    <AssemblyName>Terminal.Gui</AssemblyName>
    <DocumentationFile>bin\Release\Terminal.Gui.xml</DocumentationFile>
    <GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
    <!--<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>-->
    <PackageId>Terminal.Gui</PackageId>
    <PackageLicenseExpression>MIT</PackageLicenseExpression>
    <PackageProjectUrl>https://github.com/migueldeicaza/gui.cs/</PackageProjectUrl>
    <RepositoryUrl>https://github.com/migueldeicaza/gui.cs.git</RepositoryUrl>
    <RepositoryType>git</RepositoryType>
    <IncludeSymbols>true</IncludeSymbols>
    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
    <!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
    <!-- Embed source files that are not tracked by the source control manager in the PDB -->
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
...
  </PropertyGroup>

I've also tried (no .git at end):

    <RepositoryUrl>https://github.com/migueldeicaza/gui.cs</RepositoryUrl>
    <RepositoryType>git</RepositoryType>

Note that when I run my Github Action, I don't get the warnings; it only happens locally.

image

I've scoured all the linked issues and tried a bunch of things, but no joy.

tig commented 1 year ago

I have not been able to resolve this. I'd appreciate some help.

tig commented 11 months ago

Still unable to resolve this...

baronfel commented 11 months ago

@tig do you have an https://aka.ms/binlog that you could share from doing the pack? It seems like the sourcelink git targets may not be able to access some relevant information on your device specifically, but without a binlog it's very hard to guess why.

tig commented 11 months ago

found the issue right after I posted this: I don't use https for git. I use SSH via a .ssh/config file.

Changing my remote to use HTTP fixed it.