Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding alternative for single file publish #274

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}

// 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 @@
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 Expand Up @@ -383,7 +401,7 @@
}

public void AddBinaryLogger(
string binaryLogFilePath = null,

Check warning on line 404 in src/Buildalyzer/ProjectAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Build (macos-12)

Cannot convert null literal to non-nullable reference type.
BinaryLogger.ProjectImportsCollectionMode collectProjectImports = BinaryLogger.ProjectImportsCollectionMode.Embed) =>
AddBuildLogger(new BinaryLogger
{
Expand Down
Loading