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

ContinuousIntegrationBuild only works if PathMap is also specified? #11920

Closed
zanaptak opened this issue Aug 5, 2021 · 2 comments · Fixed by #11921
Closed

ContinuousIntegrationBuild only works if PathMap is also specified? #11920

zanaptak opened this issue Aug 5, 2021 · 2 comments · Fixed by #11921

Comments

@zanaptak
Copy link
Contributor

zanaptak commented Aug 5, 2021

Using Source Link + ContinuousIntegrationBuild without PathMap fails to produce a source linked or deterministic package.

image

Additionally defining <PathMap>C:\projectdir\=/_/</PathMap> succeeds.

image

Is it intended to require this parameter?

An equivalent C# project does not require defining PathMap. According to build logs, the C# project is executing the following task which is absent from the F# log:

09:32:19.117   2:6>Target "_SetPathMapFromSourceRoots: (TargetId:133)" in file "C:\Program Files\dotnet\sdk\5.0.302\Roslyn\Microsoft.Managed.Core.targets" from project "C:\code\sandbox\d2\DeterministicCs\DeterministicCs.csproj" (target "CoreCompile" depends on it):
                   Added Item(s): 
                       _TopLevelSourceRoot=
                           C:\Users\zaphod\.nuget\packages\
                                   EscapedKey=C:\Users\zaphod\.nuget\packages\
                                   EscapedValue=/_1/
                                   MappedPath=/_1/
                                   RepositoryUrl=
                   Added Item(s): 
                       _TopLevelSourceRoot=
                           C:\Program Files\dotnet\sdk\NuGetFallbackFolder\
                                   EscapedKey=C:\Program Files\dotnet\sdk\NuGetFallbackFolder\
                                   EscapedValue=/_2/
                                   MappedPath=/_2/
                                   RepositoryUrl=
                   Added Item(s): 
                       _TopLevelSourceRoot=
                           C:\code\sandbox\d2\DeterministicCs\
                                   EscapedKey=C:\code\sandbox\d2\DeterministicCs\
                                   EscapedValue=/_/
                                   MappedPath=/_/
                                   RepositoryUrl=https://github.com/zanaptak/DeterministicCs.git
                                   RevisionId=f8c3a49e0b1515e80dcdb4d68a47df98d3f2a804
                                   ScmRepositoryUrl=https://github.com/zanaptak/DeterministicCs.git
                                   SourceControl=git
                   Set Property: PathMap=C:\Users\zaphod\.nuget\packages\=/_1/,C:\Program Files\dotnet\sdk\NuGetFallbackFolder\=/_2/,C:\code\sandbox\d2\DeterministicCs\=/_/,

Repro steps

F#:

git clone https://github.com/zanaptak/DeterministicFs.git
cd DeterministicFs

Bad package, no PathMap:

dotnet clean && dotnet pack -p:ContinuousIntegrationBuild=true

Good package, specify PathMap:

dotnet clean && dotnet pack -p:ContinuousIntegrationBuild=true -p:PathMap="$(Join-Path (Get-Location) '')=/_/"

C#, good package, no PathMap:

git clone https://github.com/zanaptak/DeterministicCs.git
cd DeterministicCs
dotnet clean && dotnet pack -p:ContinuousIntegrationBuild=true

Related information

Provide any related information (optional):

  • Operating system

Windows 10

  • .NET Runtime kind (.NET Core, .NET Framework, Mono)

.NET Core
5.0.302
6.0.100-preview.6.21355.2

@baronfel
Copy link
Member

baronfel commented Aug 5, 2021

Pretty sure this is just a missed task from when I implemented the MapSourceRoots functionality about a year ago.

Looking at the roslyn targets that we started to copy from, there's a section right below the path mapping section I brought over that defines the target that you've discovered is missing: https://github.com/dotnet/roslyn/blob/86ff365d5d28fddd4a4738cf1d9d101522dffd50/src/Compilers/Core/MSBuildTask/Microsoft.Managed.Core.targets#L259-L292

the immediate fix would be to bring that over and verify that it gets called to set the PathMap correctly, but the longer term fix still remains that these targets need to be pushed down into a common layer for all languages to consume (as tracked here)

@baronfel
Copy link
Member

baronfel commented Aug 5, 2021

yep, when I add this target to a Directory.Build.targets in a project I already pack with sourcelink, and run the build with dotnet pack -bl -p:Deterministic=true -p:ContinuousIntegrationBuild=true to trigger all the necessary conditions, dotnet validate returns the following status:

proj-info git:(console-app) > dotnet validate package local src/Ionide.ProjInfo/bin/Debug/Ionide.ProjInfo.1.0.0.nupkg
Validating /Users/chethusk/oss/proj-info/src/Ionide.ProjInfo/bin/Debug/Ionide.ProjInfo.1.0.0.nupkg
• Source Link: ✅ Valid

• Deterministic (dll/exe): ✅ Valid

• Compiler Flags: ❌ Missing
    Ensure you're using at least the 3.1.400 SDK or MSBuild 16.7:
    The following assemblies have not been compiled with a new enough compiler:
    lib\net5.0\Ionide.ProjInfo.dll

So we're as complete as we can be at this time, given that the F# compiler doesn't support writing compiler flags to PDBs for reproducibility as of yet.

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

Successfully merging a pull request may close this issue.

2 participants