Skip to content

Packing the VMR into a tarball produces a tarball that fails to build #3112

Closed
dotnet/installer
#15226

Description

@omajid

For distributions like Fedora, we use a tarball containing the source code of a project as one of the inputs to the build system. This model was supported in the old arcade-powered-source-build where we could build a source tarball and then build that in the Fedora build system offline.

This doesn't work with the VMR, at least not with the "obvious" approach. Am I using it wrong? Is there another set of steps to do this? Is this something that's still in development?

Steps to Reproduce

$ git clone https://github.com/dotnet/dotnet
$ cd dotnet
$ git rev-parse HEAD
b8bc661a7429baa89070f3bee636b7fbc1309489
$ git archive -o dotnet-$(git rev-parse HEAD).tar.gz --prefix=dotnet-$(git rev-parse HEAD)/ HEAD .
$ cd ..
$ tar xf dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489.tar.gz
$ cd dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489
$ ./prep.sh
$ ./build.sh --online

        Determining projects to restore...                                                                                    Restored /home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/packages/restored/ArcadeBootstrapPackage/microsoft.dotnet.arcade.sdk/7.0.0-beta.22462.6/tools/Tools.proj (in 137 ms).                                  [SourceBuiltSdkResolver] Looking for SDK Microsoft.NET.Sdk. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/7.0.0-beta.22462.6' at '/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/packages/restored/ArcadeBootstrapPackage/microsoft.dotnet.arcade.sdk/7.0.0-beta.22462.6/'                                      [SourceBuiltSdkResolver] Looking for SDK Microsoft.DotNet.Arcade.Sdk. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/7.0.0-beta.22462.6' at '/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/packages/restored/ArcadeBootstrapPackage/microsoft.dotnet.arcade.sdk/7.0.0-beta.22462.6/'                            [SourceBuiltSdkResolver] Overriding Microsoft.DotNet.Arcade.Sdk with 'ARCADE'                                         [SourceBuiltSdkResolver] Looking for SDK Microsoft.NET.SDK.WorkloadAutoImportPropsLocator. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/7.0.0-beta.22462.6' at '/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/packages/restored/ArcadeBootstrapPackage/microsoft.dotnet.arcade.sdk/7.0.0-beta.22462.6/'       [SourceBuiltSdkResolver] Looking for SDK Microsoft.DotNet.ILCompiler. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/7.0.0-beta.22462.6' at '/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/packages/restored/ArcadeBootstrapPackage/microsoft.dotnet.arcade.sdk/7.0.0-beta.22462.6/'                            [SourceBuiltSdkResolver] Looking for SDK Microsoft.NET.ILLink.Tasks. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/7.0.0-beta.22462.6' at '/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/packages/restored/ArcadeBootstrapPackage/microsoft.dotnet.arcade.sdk/7.0.0-beta.22462.6/'                             [SourceBuiltSdkResolver] Looking for SDK Microsoft.NET.SDK.WorkloadManifestTargetsLocator. Detected config(s) in
 env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/7.0.0-beta.22462.6' at '/home/omajid/devel/dotnet/dotnet-b8bc661a7429b
aa89070f3bee636b7fbc1309489/packages/restored/ArcadeBootstrapPackage/microsoft.dotnet.arcade.sdk/7.0.0-beta.22462.6/' 
        Determining projects to restore...                                                                            
        Restored /home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/src/source-build-reference-
packages/artifacts/source-build/self/src/eng/NoOp.csproj (in 32 ms).                                                  
    /home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/src/source-build-reference-packages/arti
facts/source-build/self/package-cache/microsoft.build.tasks.git/1.2.0-beta-22429-01/build/Microsoft.Build.Tasks.Git.ta
rgets(25,5): error : Unable to locate repository with working directory that contains directory '/home/omajid/devel/do
tnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/src/source-build-reference-packages/artifacts/source-build/self/src/eng'. [/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/src/source-build-reference-package
s/artifacts/source-build/self/src/eng/NoOp.csproj] [/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc
1309489/packages/restored/ArcadeBootstrapPackage/microsoft.dotnet.arcade.sdk/7.0.0-beta.22462.6/tools/Build.proj]     
    ##vso[task.logissue type=error;sourcepath=/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/src/source-build-reference-packages/artifacts/source-build/self/package-cache/microsoft.build.tasks.git/1.2.0-beta-2
2429-01/build/Microsoft.Build.Tasks.Git.targets;linenumber=25;columnnumber=5;code=;]Unable to locate repository with w
orking directory that contains directory '/home/omajid/devel/dotnet/dotnet-b8bc661a7429baa89070f3bee636b7fbc1309489/sr
c/source-build-reference-packages/artifacts/source-build/self/src/eng'. [/home/omajid/devel/dotnet/dotnet-b8bc661a7429
baa89070f3bee636b7fbc1309489/src/source-build-reference-packages/artifacts/source-build/self/src/eng/NoOp.csproj%5D

Other Information

Activity

  1. MichaelSimons commented on Nov 11, 2022

    @MichaelSimons
    Member

    Thanks for the raising this issue @omajid. The VMR is considered experimental at this point. This is something we will have to get addressed prior to Preview 1.

    cc @premun

  2. premun commented on Nov 11, 2022

    @premun
    Member

    I presume the --clean-while-building switch from VMR's instructions is irrelevant (unwanted?) here?

  3. MichaelSimons commented on Nov 11, 2022

    @MichaelSimons
    Member

    I presume the --clean-while-building switch from VMR's instructions is irrelevant (unwanted?) here?

    The lack of --clean-while-building is irrelevant. This is just a flag that proactively cleans up artifacts while building mainly used to reduce the disk space required to build. It is omitted often if you want to diagnose issues.

  4. added
    area-infra
    on Nov 17, 2022
  5. MichaelSimons commented on Nov 17, 2022

    @MichaelSimons
    Member

    [Triage] This feels like it is source-link related. We likely need to extract the minimal info needed by source-link. When fixing, please verify that the build still works if the extracted tarball is placed within the context of another git repo.

  6. MichaelSimons commented on Dec 1, 2022

    @MichaelSimons
    Member

    [Triage] Given the importance of being able to create a tarball from the VMR to our distro maintainer partners, we should also validate this in CI.

  7. moved this from 8.0 Backlog to 8.0 Preview 1 in .NET Source Buildon Dec 8, 2022
  8. crummel commented on Dec 15, 2022

    @crummel
    Contributor
  9. premun commented on Dec 20, 2022

    @premun
    Member

    From the sourcelink docs it seems we only need 2 very basic things:

    • The .git/HEAD file with the SHA of the current commit
    • The .git/config file pointing to the dotnet/dotnet repo (e.g. [remote "origin"] url="http://github.com/dotnet/dotnet")
  10. 2 remaining items

  11. premun commented on Jan 9, 2023

    @premun
    Member

    Binlog: Build_0109160911.zip

    Repro steps:

    1. Start the default codespace from https://github.com/premun/dotnet/tree/premun/pack
    2. ./eng/pack-sources.sh
    3. cd artifacts/packages
    4. tar xf dotnet-0153aa339cccb301573e1b68b1a8f8b5daa94557.tar.gz
    5. cd dotnet-0153aa339cccb301573e1b68b1a8f8b5daa94557
    6. chmod +x *.sh
    7. ./prep.sh
    8. ./build.sh --clean-while-building --online
  12. premun commented on Jan 9, 2023

    @premun
    Member

    Oh, it seems to be happening on the VMR itself as well. Maybe something about my environment..

  13. premun commented on Jan 9, 2023

    @premun
    Member

    Ah, ignore this, it's the missing

    unset RepositoryName

  14. premun commented on Jan 9, 2023

    @premun
    Member

    Weirdly enough, git archive doesn't preserve file permissions and the execute goes away on the prep/build scripts

  15. mmitche commented on Jan 11, 2023

    @mmitche
    Member

    @premun and I looked at this a bit closer. The issue is just that installer is attempting to git operations even though they are not required.

    https://github.com/dotnet/dotnet/blob/main/src/installer/src/redist/targets/GenerateMSIs.targets#L73-L77 should only be run if CombinedBuildNumberAndRevision is empty before this line: https://github.com/dotnet/dotnet/blob/main/src/installer/src/redist/targets/GenerateMSIs.targets#L88

    In official builds, we do not ever need to get the git commit count.

  16. premun commented on Jan 11, 2023

    @premun
    Member

    Should we have some workaround for non-official builds? In case people download the sources only?
    It seems we wouldn't need the git commit count for this purpose?

    Is the build done by partners also going to have properties initialized like it was an official one?

  17. mmitche commented on Jan 11, 2023

    @mmitche
    Member

    Should we have some workaround for non-official builds? In case people download the sources only? It seems we wouldn't need the git commit count for this purpose?

    Is the build done by partners also going to have properties initialized like it was an official one?

    We could just have those users set a property, or use the date.

  18. premun commented on Jan 11, 2023

    @premun
    Member

    I have an idea - should the script, that exports the sources for you, write this property somewhere with the current git commit count of the VMR?

    Is there a suitable .props file that would be good for this?

    We could just add <GitCommitCount>$(git rev-list --count HEAD)</GitCommitCount> while we have the VMR available when creating the source archive

  19. mmitche commented on Jan 11, 2023

    @mmitche
    Member

    I don't think it's necessary. It's only there for dev builds, and only for MSI generation. I would take a look at Arcade's infra for MSI generation and see what it uses for the same purpose. Maybe we can just use that.

    /cc @marcpopMSFT @dsplaisted if they have any insight here.

  20. premun commented on Jan 12, 2023

    @premun
    Member

    I confirm that setting the GitCommitCount property gave me a successful build. Will deal with this in the associated PR

  21. dsplaisted commented on Jan 12, 2023

    @dsplaisted
    Member

    Briefly looking at how GitCommitCount is used in dotnet/installer, it looks like we were getting the git information for each repository for the sourcebuild tarball. I'm guessing that doesn't apply to the VMR build.

    The other use is for creating the MSIs. If we want to be able to create the MSIs from the VMR build then we will need to figure out what to do. @premun's idea of including the git information in the tarball would work. But I think it will be a while before we need to build the MSIs this way from a zipped-up copy of the VMR.

  22. mmitche commented on Jan 12, 2023

    @mmitche
    Member

    @dsplaisted For non-dev builds of the tarball, it should be fine to simply not have a GitCommitCount.

        <Exec Command="git rev-list --count HEAD"
              ConsoleToMSBuild="true"
              Condition=" '$(GitCommitCount)' == '' ">
          <Output TaskParameter="ConsoleOutput" PropertyName="GitCommitCount" />
        </Exec>
    
        <Error Condition=" '$(OfficialBuild)' == 'true' And '$(_PatchNumber)' == '' "
               Text="_PatchNumber should not be empty in an official build. Check if there were changes in Arcade." />
    
        <PropertyGroup>
          <GitCommitCount>$(GitCommitCount.PadLeft(6,'0'))</GitCommitCount>
    
          <!-- This number comes from arcade and combines the date based build number id and the revision (incremental number per day) -->
          <CombinedBuildNumberAndRevision>$(_PatchNumber)</CombinedBuildNumberAndRevision>
          <!-- Fallback to commit count when patch number is not set. This happens only during CI. -->
          <CombinedBuildNumberAndRevision Condition=" '$(CombinedBuildNumberAndRevision)' == '' ">$(GitCommitCount)</CombinedBuildNumberAndRevision>
    

    The source does not use the git commit count except in cases where we are not doing an official build. IIRC the typical build of the tarball/VMR is official. So I think the thing to do here is to sink the git commit count calculation task until we know we have to use it.

  23. premun commented on Jan 13, 2023

    @premun
    Member

    Thanks all, this did the trick:
    dotnet/installer@fa708d7

    (not calling git it when it's not needed)

  24. moved this from In Progress to Done in .NET Source Buildon Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-infra

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions