cake-contrib / Cake.Incubator

This project contains various experimental but useful extension methods and aliases for Cake
http://cakebuild.net/api/Cake.Incubator/
Other
19 stars 26 forks source link

ParseProject doesn't respect settings from Directory.Build.props #231

Open christianbumann opened 9 months ago

christianbumann commented 9 months ago

In the file 'src\Directory.Build.props\' settings for all projects were done.

example:

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

Parsing the project

var projectInfo = context.ParseProject(project.Path, "Debug");
projectInfo.OutputPaths[0] // this returns e.g. C:/xyz/src/xyz/bin/Debug/net472'

Setting the AppendTargetFrameworkToOutputPath in the project file itself

var projectInfo = context.ParseProject(project.Path, "Debug");
projectInfo.OutputPaths[0] // this returns e.g. C:/xyz/src/xyz/bin/Debug'

Expected Behavior

Respect settings from Directory.Build.props

Current Behavior

It doesn't respect settings from Directory.Build.props

Additional information

NeishaS commented 3 days ago

I can confirm this issue as well.

I attempted to set the TargetFramework in Directory.Build.props with the following configuration:

<Project>
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>
</Project>

Subsequently, I removed the TargetFramework from the .csproj files of multiple projects in my solution. My objective was to streamline the process of upgrading the .NET framework version across all projects from a single location. The projects build without any issues in Visual Studio.

However, when invoking ParseProject within my CICD scripts, I noticed that in the CustomProjectParserResult object, the TargetFrameworkVersion property was set to null and the IsNetCore property was set to false. This resulted in the IsWebApplication() method returning false.

I'm currently using Cake.Incubator Version=8.0.0.

Addressing this issue would be greatly appreciated as it would enable the use of Directory.Build.props and help avoid redundancy in defining the same property values across multiple project files within a solution.