Skip to content

Commit

Permalink
feat: adding alternative for single file publish
Browse files Browse the repository at this point in the history
  • Loading branch information
phmonte committed May 29, 2024
1 parent 8260134 commit 56d9920
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ If you want to change the configured properties before loading or compiling the

Be careful though, you may break the ability to load, compile, or interpret the project if you change the MSBuild properties.


## Publish SingleFile
If your application's output is a single file, you will need to provide the path to the following DLLs:

-MsBuildPipeLogger.Logger.dll
-Buildalyzer.logger.dll

Variable name: LoggerPathDll

See related issue [224](https://github.com/phmonte/Buildalyzer/issues/224)
msbuild needs the physical address of the logger, for this reason it is not possible to use single file publish without informing this route.

Remembering that if the files are in the root where the project is running, it is not necessary to inform the path.
## Binary Log Files

Buildalyzer can also read [MSBuild binary log files](http://msbuildlog.com/):
Expand Down
1 change: 1 addition & 0 deletions src/Buildalyzer/Environment/EnvironmentVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ public static class EnvironmentVariables
public const string MSBUILDDISABLENODEREUSE = nameof(MSBUILDDISABLENODEREUSE);
public const string MSBuildExtensionsPath = nameof(MSBuildExtensionsPath);
public const string MSBuildSDKsPath = nameof(MSBuildSDKsPath);
public const string LoggerPathDll = nameof(LoggerPathDll);
}
20 changes: 19 additions & 1 deletion src/Buildalyzer/ProjectAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ private string GetCommand(
}

// Get the logger arguments (/l)
string loggerPath = typeof(BuildalyzerLogger).Assembly.Location;
string loggerPath = GetLoggerPath();

bool logEverything = _buildLoggers.Count > 0;
string loggerArgStart = "/l"; // in case of MSBuild.exe use slash as parameter prefix for logger
if (isDotNet)
Expand Down Expand Up @@ -312,6 +313,23 @@ private string GetCommand(
return fileName;
}

private static string GetLoggerPath()
{
string loggerPath = typeof(BuildalyzerLogger).Assembly.Location;
if (!string.IsNullOrEmpty(loggerPath))
{
return loggerPath;
}

string? loggerDllPathEnv = System.Environment.GetEnvironmentVariable(Environment.EnvironmentVariables.LoggerPathDll);
if (string.IsNullOrEmpty(loggerDllPathEnv))
{
throw new ArgumentException($"The dll of {nameof(BuildalyzerLogger)} is required");
}

return loggerDllPathEnv;
}

private static string FormatArgument(string argument)
{
// Escape inner quotes
Expand Down

0 comments on commit 56d9920

Please sign in to comment.