ionide / proj-info

Parse and evaluate MsBuild project files
MIT License
64 stars 37 forks source link

Missing source files and embedded items compared to `dotnet build --no-dependencies` #179

Closed safesparrow closed 1 year ago

safesparrow commented 1 year ago

Describe the bug I want to use the ProjInfo library to generate fsc args from an .fsproj - so that I can then run type-checking/compilation tests using the results.

My problem is that ProjectLoader.getProjectInfo doesn't return all the command line args that dotnet build --no-dependencies uses when launching fsc.

To Reproduce Steps to reproduce the behaviour:

  1. Use ProjInfo to crack the FSharp.Compiler.ComponentTests.fsproj in the F# compiler codebase. I've attached the code I'm using below.
  2. See that the result does not include the following options/source files:
    --embed:..\..\artifacts\obj\FSharp.Compiler.ComponentTests\Debug\net7.0\buildproperties.fs
    --embed:..\..\artifacts\obj\FSharp.Compiler.ComponentTests\Debug\net7.0\FSharp.Compiler.ComponentTests.AssemblyInfo.fs
    --sourcelink:..\..\artifacts\obj\FSharp.Compiler.ComponentTests\Debug\net7.0\FSharp.Compiler.ComponentTests.sourcelink.json
    --keyfile:$PACKAGES$\microsoft.dotnet.arcade.sdk\8.0.0-beta.22552.1\tools\snk/MSFT.snk
    --refout:..\..\artifacts\obj\FSharp.Compiler.ComponentTests\Debug\net7.0\refint\FSharp.Compiler.ComponentTests.dll
    ..\..\artifacts\obj\FSharp.Compiler.ComponentTests\Debug\net7.0\buildproperties.fs
    ..\..\artifacts\obj\FSharp.Compiler.ComponentTests\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.fs

Expected behaviour Options/args that can be used to successfully compile the project - same ones that dotnet build --no-dependencies uses.

Screenshots Screenshots showing MSBuild properties used by ProjInfo (right) and dotnet build --no-dependencies (left):

image

And FSC task properties:

image

Code used to call ProjInfo

let dir = Path.GetDirectoryName projectFile
let _ = Init.init (DirectoryInfo dir) None
let props = []
ProjectLoader.getProjectInfo projectFile props BinaryLogGeneration.Off

.fsproj:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <OutputType>exe</OutputType>
    </PropertyGroup>

    <ItemGroup>
        <Compile Include="Program.fs" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Ionide.ProjInfo.FCS" Version="0.61.0" />

        <PackageReference Include="Microsoft.Build.Framework" Version="17.4.0" ExcludeAssets="runtime" />
        <PackageReference Include="Microsoft.Build.Locator" Version="1.5.5" />
        <PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.4.0" ExcludeAssets="runtime" />
        <PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.4.0" ExcludeAssets="runtime" />
    </ItemGroup>

</Project>

Environment (please complete the following information):

TheAngryByrd commented 1 year ago

Can you generate a binlog from dotnet build --no-dependencies? This would help figure out what Targets/Properties you would want to set when cracking a project.

safesparrow commented 1 year ago

Actually I think this can be closed now that https://github.com/ionide/proj-info/pull/183 has been merged.