Open mcreek opened 2 years ago
Buildalyzer doesn't actually process the project file on its own (at least not beyond very rudimentary parsing to figure out how to call MSBuild), and the values in IAnalyzerResult
come directly from MSBuild logging. So that's all to say that if the OutputPath
and OutDir
props aren't coming over correctly, then it's because MSBuild isn't resolving them as you expect when Buildalyzer calls it.
There's a few reasons why this could be:
The best way to diagnose what's going on here is probably to log what Buildalyzer is doing and then do it yourself from the command line. For example:
StringWriter log = new StringWriter();
AnalyzerManager manager = new AnalyzerManager(
new AnalyzerManagerOptions
{
LogWriter = log
});
// ...
System.Diagnostics.Debug.WriteLine(log.ToString());
That'll let you see exactly what command line Buildalyzer ran and from where and then you can run it yourself and compare.
The next step after that would probably be to generate a binary log and open it with the Structured Log Viewer. That should let you see exactly what's going on under the hood, how and why those output values are being set the way they are, and where or if the common.props file is being processed:
IProjectAnalyzer analyzer = manager.GetProject(projectFile);
analyzer .AddBinaryLogger("myproject.binlog")));
To really get down to what the differences are, use the Project System Tools extension to generate a binary log file from Visual Studio too and compare the two.
Thank you for response and the description how to analyze it. I will try to analyze it but I will need some time for it.
Please use Directory.Build.props and Directory.Build.targets instead of "common.props".
OutputPath
property is a relativ path and BaseOutputPath
should be used.
see also .NET 8.0 SDK Artifacts output layout
@mcreek, Do you have any updates on this?
This might be helpful. OutputPath vs OutDir
With Buildalyzer (version 4.1.3) I'm analyzing CSPROJ files which are part of a solution file. For build-output configuration I'm using one common "common.props" file instead of configuring it at all csproj files individually.
Example of file "common.props"
This "common.props" file is included in each csproj file with
and the "OutputPath" Property is removed in each csproj file .
My directory structure is:
Analyzing the projects with code:
This will print out for "OutputPath": "\<drive>\SampleApp\src\SampleAppProj_1\\build\bin\debug\" instead of "\<drive>\SampleApp\build\bin\debug\" Same for "OutDir" property.
I'am doing something wrong? How can I get the correct "OutputPath" and "OutDir"?