fsprojects / fsprojects/Paket

Question: Evaluating MSBuild-Properties from paket pack

Open
#1,949 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement msbuild proj sdk: verbose sdk
Dominant language
F#
Stars
2.1k
Forks
528
Avg merge
1d 12m
Merged PRs (30d)
54

Description

We want to split up a huge C# project with around 400 projects into smaller components which should be delivered as nuget packages. I am just looking into Paket because it seems to be very promising, so please be gentle if this question seems dumb.

Description

In our C# project files we have a global property called $(RootCodeDir) which is set to the root directory of our software if not set from outside:

<RootCodeDir Condition=" '$(RootCodeDir)' == '' ">$(MSBuildThisFileDirectory.Substring(0, $(MSBuildThisFileDirectory.IndexOf(`repo`))))</RootCodeDir>

With this trick we can ensure that every assembly is written to the same output directory, f.i.:
$(RootCodeDir)\repo\bin\debug

And if we move around the folder of the project we do not have to change the project file and fiddle with changing the path at multiple locations from ...... to ....

In the example below I have removed the $(RootCodeDir) from the OutputPath, but as pack symbols tries to pack some global files with $(RootCodeDir) in their path, it fails.

c:\repo\path\to\my\project>...paket\paket.exe --verbose pack symbols output out buildplatform x86 buildconfig Release_Package
Paket version 3.21.0.0
found: c:\repo\paket.dependencies
Parsing c:\repo\paket.dependencies
Loading assembly metadata for c:\repo\path\to\my\project\bin\x86\Release_Package\my.dll
Paket failed with:
Could not find a part of the path 'c:\repo\path\to\my\project$(RootCodeDir)\repo'.
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator1.CommonInit() at System.IO.FileSystemEnumerableIterator1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler1 resultHandler, Boolean checkHost) at System.IO.Directory.GetFiles(String path, String searchPattern) at <StartupCode$Paket-Core>.$ProjectFile.GetCompileItems@1626.Invoke(CompileItem compileItem) at Microsoft.FSharp.Collections.IEnumerator.map@111.DoMoveNext(b& ) at Microsoft.FSharp.Collections.IEnumerator.MapEnumerator1.System-Collections-IEnumerator-MoveNext()
at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@713[T,TResult](ConcatEnumerator2 x, Unit unitVar0) at Microsoft.FSharp.Collections.IEnumerator.map@111.DoMoveNext(b& ) at Microsoft.FSharp.Collections.IEnumerator.MapEnumerator1.System-Collections-IEnumerator-MoveNext()
at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable1 source) at Paket.PackageProcess.convertToSymbols(ProjectFile projectFile, Boolean includeReferencedProjects, TemplateFile templateFile) at Paket.PackageProcess.optWithSymbols@185-1.GenerateNext(IEnumerable1& next)
at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase1.MoveNextImpl() at Paket.PackageProcess.allTemplates@209-2.GenerateNext(IEnumerable1& next)
at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase1.MoveNextImpl() at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@706[T,TResult](ConcatEnumerator2 x, Unit unitVar0)
at Microsoft.FSharp.Collections.IEnumerator.map@111.DoMoveNext(b& )
at Microsoft.FSharp.Collections.IEnumerator.MapEnumerator1.System-Collections-IEnumerator-MoveNext() at Microsoft.FSharp.Collections.Generator.Microsoft-FSharp-Collections-Generator-Generator-1-get_Apply@542-1.Invoke(Unit unitVar0) at Microsoft.FSharp.Collections.Generator.appG[a](Generator1 g)
at Microsoft.FSharp.Collections.Generator.EnumeratorWrappingLazyGenerator1.System-Collections-IEnumerator-MoveNext() at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable1 source)
at Paket.PackageProcess.Pack[a](String workingDir, DependenciesFile dependenciesFile, String packageOutputPath, FSharpOption1 buildConfig, FSharpOption1 buildPlatform, FSharpOption1 version, IEn umerable1 specificVersions, FSharpOption1 releaseNotes, FSharpOption1 templateFile, FSharpOption1 excludedTemplates, Boolean lockDependencies, Boolean minimumFromLockFile, Boolean pinProjectRefere nces, Boolean symbols, Boolean includeReferencedProjects, FSharpOption1 projectUrl)
at Paket.Program.main@403-20.Invoke(ParseResults1 results) at Paket.Program.processWithValidation[T](Boolean silent, FSharpFunc2 validateF, FSharpFunc2 commandF, ParseResults1 result)
at Paket.Program.main$cont@380(ParseResults`1 results, Boolean silent, Unit unitVar)
at Paket.Program.main()

Expected behavior

Adding and using MSBuild properties in my csproj file should work.;-)

Known workarounds

Ok. I workaround would be (and I can confirm it works) to add relative paths again instead of the property, but then I am not that free any more regarding the placement of single projects/components in my directory tree.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ProjectFile.GetCompileItems around the reported line 1626 and PackageProcess.convertToSymbols, then reproduce the paket pack symbols command from the issue using the shown MSBuild property. Done means packing symbols no longer treats $(RootCodeDir) as a literal path and the project files are included from their resolved locations.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.