Code Monkey home page Code Monkey logo

invoke-msbuild's Introduction

Invoke-MsBuild PowerShell Module

A PowerShell module to make building projects and solutions with MsBuild easy. It provides features such as:

  • Check if the build succeeded or failed
  • Automatically open the build log file when the build fails
  • View the build output in the current console window, a new window, or not at all
  • Fire-and-forget building (via the -PassThru switch)

The module simply passes through any MsBuild command-line parameters you supply, so it supports all functionality (e.g. project types, targets, etc.) that you would get by calling MsBuild directly. The module builds using the Visual Studio Command Prompt when available in order to support more project types that MsBuild.exe alone may not support, such as XNA projects.

Getting Started

You can either download the Invoke-MsBuild.psm1 file from the Releases page directly, or install the module from the PowerShell Gallery.

Here is an example of how to import the Invoke-MsBuild module into your powershell session and call it:

Import-Module -Name "C:\PathTo\Invoke-MsBuild.psm1"
Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln"

When the -PassThru switch is provided, the process being used to run MsBuild.exe is returned.

When the -PassThru switch is not provided, a hash table with the following properties is returned:

  • BuildSucceeded = $true if the build passed, $false if the build failed, and $null if we are not sure.
  • BuildLogFilePath = The path to the build's log file.
  • BuildErrorsLogFilePath = The path to the build's error log file.
  • ItemToBuildFilePath = The item that MsBuild ran against.
  • CommandUsedToBuild = The full command that was used to invoke MsBuild. This can be useful for inspecting what parameters are passed to MsBuild.exe.
  • Message = A message describing any problems that were encountered by Invoke-MsBuild. This is typically an empty string unless something went wrong.
  • MsBuildProcess = The process that was used to execute MsBuild.exe.
  • BuildDuration = The amount of time the build took to complete, represented as a TimeSpan.

Examples

$buildResult = Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln"

if ($buildResult.BuildSucceeded -eq $true)
{
  Write-Output ("Build completed successfully in {0:N1} seconds." -f $buildResult.BuildDuration.TotalSeconds)
}
elseif ($buildResult.BuildSucceeded -eq $false)
{
  Write-Output ("Build failed after {0:N1} seconds. Check the build log file '$($buildResult.BuildLogFilePath)' for errors." -f $buildResult.BuildDuration.TotalSeconds)
}
elseif ($null -eq $buildResult.BuildSucceeded)
{
  Write-Output "Unsure if build passed or failed: $($buildResult.Message)"
}

Perform the default MsBuild actions on the Visual Studio solution to build the projects in it, and returns a hash table containing the results. The PowerShell script will halt execution until MsBuild completes.


$process = Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln" -PassThru

while (!$process.HasExited)
{
  Write-Host "Solution is still building..."
  Start-Sleep -Seconds 1
}

Perform the default MsBuild actions on the Visual Studio solution to build the projects in it. The PowerShell script will not halt execution; instead it will return the process running MsBuild.exe back to the caller while the build is performed. You can check the process's HasExited property to check if the build has completed yet or not.


if ((Invoke-MsBuild -Path $pathToSolution).BuildSucceeded -eq $true)
{
  Write-Output "Build completed successfully."
}

Perform the build against the file specified at $pathToSolution and checks it for success in a single line.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -MsBuildParameters "/target:Clean;Build" -ShowBuildOutputInNewWindow

Cleans then Builds the given C# project. A window displaying the output from MsBuild will be shown so the user can view the progress of the build without it polluting their current terminal window.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildOutputInCurrentWindow

Builds the given C# project and displays the output from MsBuild in the current terminal window.


Invoke-MsBuild -Path "C:\MySolution.sln" -MsBuildParameters "/target:Clean;Build /property:Configuration=Release;Platform=x64;BuildInParallel=true /verbosity:Detailed /maxcpucount"

Cleans then Builds the given solution, specifying to build the project in parallel in the Release configuration for the x64 platform. Here the shorter "Params" alias is used instead of the full "MsBuildParameters" parameter name.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildOutputInNewWindow -PromptForInputBeforeClosing -AutoLaunchBuildLogOnFailure

Builds the given C# project. A window displaying the output from MsBuild will be shown so the user can view the progress of the build, and it will not close until the user gives the window some input after the build completes. This function will also not return until the user gives the window some input, halting the powershell script execution. If the build fails, the build log will automatically be opened in the default text viewer.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath "C:\BuildLogs" -KeepBuildLogOnSuccessfulBuilds -AutoLaunchBuildErrorsLogOnFailure

Builds the given C# project. The build log will be saved in "C:\BuildLogs", and they will not be automatically deleted even if the build succeeds. If the build fails, the build errors log will automatically be opened in the default text viewer.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath PathDirectory

Builds the given C# project. The keyword 'PathDirectory' is used, so the build log will be saved in "C:\Some Folder", which is the same directory as the project being built (i.e. directory specified in the Path).


Invoke-MsBuild -Path "C:\Database\Database.dbproj" -P "/t:Deploy /p:TargetDatabase=MyDatabase /p:TargetConnectionString=`"Data Source=DatabaseServerName`;Integrated Security=True`;Pooling=False`" /p:DeployToDatabase=True"

Deploy the Visual Studio Database Project to the database "MyDatabase". Here the shorter "P" alias is used instead of the full "MsBuildParameters" parameter name. The shorter alias' of the MsBuild parameters are also used; "/t" instead of "/target", and "/p" instead of "/property".


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -WhatIf

Returns the result object containing the same property values that would be created if the build was ran with the same parameters. The BuildSucceeded property will be $null since no build will actually be invoked. This will display all of the returned object's properties and their values.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" > $null

Builds the given C# project, discarding the result object and not displaying its properties.

Full Documentation

For a full list of available parameters, check out the latest documentation in PowerShell by using Get-Help Invoke-MsBuild -Full, or just look at the file in source control here.

Changelog

See what's changed in the application over time by viewing the changelog.

Donate

Buy me some pancakes ๐Ÿฅž for providing this PowerShell module open source and for free :)

paypal

invoke-msbuild's People

Contributors

bastrakov-sergei avatar deadlydog avatar jhecking avatar jimoneil avatar leon99 avatar mrdnk avatar nschonni avatar tdue21 avatar tibold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

invoke-msbuild's Issues

Add support for VS 2017

The Get-VisualStudioCommandPromptPath does not locate VS 2017. I admit that this is a tricky one as you can now have multiple VS 2017 instances. I would suggest using the vswhere.exe command with -legacy parameter, which can also locate downlevel VS directories.

Test run failed

I am getting error when run test.

Invoke-MsBuild : Unexpected error occurred while building "F:\Temp\Invoke-MsBuild\Tests\SolutionThatShouldBuildSuccessfully\SolutionThatShouldBuildSuccessfully.sln": Exception calling "ToDouble" with "1" argument(s): "Input string was not in a correct format."
At F:\Temp\Invoke-MsBuild\Tests\RunTests.ps1:22 char:6

  • if ((Invoke-MsBuild -Path $pathToGoodSolution).BuildSucceeded -eq $true) { Write ...
  •  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-MsBuild

Test 1 failed.
At F:\Temp\Invoke-MsBuild\Tests\RunTests.ps1:22 char:105

  • ... ssed" } else { throw "Test $testNumber failed." }
  •                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Test 1 failed.:String) [], RuntimeException
    • FullyQualifiedErrorId : Test 1 failed.

Add explicit parameters to Invoke-MSBuild

I'd like to see a Target parameter for Invoke-MSBuild added as [string[]] so we don't need to pass it as a string in MsBuildParameters.

I'd also like a Properties parameter of type [hashtable] so we could write things like this:

Invoke-MSBuild -Target Clean,Build -Properties @{Configuration='Debug';OutDir='..\artifacts\'}

Add support for .NET Framework 4.5.2

Hi, when invoking Invoke-MSBuild with PS 5 and .NET Framework 4.5.2, I get an exception saying that "'CurrentCulture' is a ReadOnly property".

See MSDN:

In the .NET Framework 4.5.2 and earlier versions, the CurrentCulture property is read-only; that is, you can retrieve the property value, but you cannot set it. To change the current culture, you assign the CultureInfo object that represents the new culture to the Thread.CurrentThread.CurrentCulture property. Starting with the .NET Framework 4.6, the CurrentCulture property is read-write; you can both set and retrieve the property's value. If you do set the property value to a CultureInfo object that represents a new culture, the value of the Thread.CurrentThread.CurrentCulture property also changes.

-MsBuildFilePath not working

Hello,
I am trying to run a command like
Invoke-MsBuild -MsBuildFilePath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe" -Path ".\SomeSln.sln" -MsBuildParameters "/property:Configuration=Release /property:Platform="x64"";
However, the output I get is not the expected. It tries to use 2022 instead of the MsBuildFilePath that I am using

cd xyz\somepath\; Invoke-MsBuild -MsBuildFilePath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe" -Path ".\SomeSln.sln" -MsBuildParameters " /property:Configuration=Release /property:Platform=`"x64`" "
WARNING: FAILED to build ".\SomeSln.sln". Please check the build log 
"C:\Users\RandomUser\AppData\Local\Temp\SomeSln.sln.msbuild.log" for details.
Name                           Value                                                               
----                           -----                                                               
Message                        FAILED to build ".\SomeSln.sln". Please check the bui...
MsBuildProcess                 System.Diagnostics.Process (cmd)                                    
BuildLogFilePath               C:\Users\RandomUser\AppData\Local\Temp\SomeSln.sln.msbuil...
BuildErrorsLogFilePath         C:\Users\RandomUser\AppData\Local\Temp\SomeSln.sln.msbuil...
BuildSucceeded                 False                                                               
ItemToBuildFilePath            .\SomeSln.sln                                           
CommandUsedToBuild             cmd.exe /k " "C:\Program Files (x86)\Microsoft Visual Studio\2022...

The buildlog just spits some things related to MsBuild missing some things, but I assume that that is because it is using a different MsBuild version
any help?
Thanks a lot!

Invoke-MsBuild takes a long time to start

I am currently writing a script for automating my pipeline. I decided to use Invoke-MsBuild for the build part, but discovered that the Invoke-MsBuild command seems to hang for a while before starting.

I do not know if this is a known issue, but I do not think it is the same issue as #11 or #13.

I added some timestamping to my script in order to seem what goes on, and this is the output:

2017-05-14T13:14:55.0336411+02:00 Starting MSBuild.
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26430.4
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 14-05-2017 13:17:15.

...

Time Elapsed 00:00:01.07
2017-05-14T13:17:16.3157579+02:00 MSBuild finished.

My code looks like this:

"$(Get-Date -f o) Starting MSBuild."

$result = Invoke-MsBuild -Path $solutionPath -ShowBuildOutputInCurrentWindow -BuildLogDirectoryPath . -KeepBuildLogOnSuccessfulBuilds -LogVerbosity n

"$(Get-Date -f o) MSBuild finished."

Apparently something is taking a lot of time, almost 2.5 minute from calling Invoke-MsBuild to MsBuild.exe actually starting.

Invoke-msbuild getting error when triggered through build definition

We are getting below error for few of the projects where rest of the projects getting compiled successfully.

$SolutionOutputPath=Join-Path $AgentFolderPath "\Src\DOTNET\Common\bin"
$BuildParameters="/target:Build /property:Configuration=Release /p:OutDir=""$SolutionOutputPath"";Platform=""AnyCPU"" /verbosity:Quiet"
$SolutionPath=Join-Path $AgentFolderpath "\Src\DOTNET\NonWebApps\ShipmentHistoryUpdateJob\ShipmentHistoryUpdateJob.csproj"
Invoke-MsBuild -Path $SolutionPath -MsBuildParameters $BuildParameters

Invoke-MsBuild : Unexpect error occured while building "D:_yyy2\OEM\POC.SM.M_1
_PS\src\Src\DOTNET\NonWebApps\ShipmentHistoryUpdateJob\ShipmentHistoryUpdateJob.csproj": Process with an Id of 10032 is not running.
At D:_yyy2\POC.SM.M_1_PS\src\Build\Library\InvokeSolutions.ps1:716 char:1

Invoke-MsBuild -Path $SolutionPath -MsBuildParameters $BuildParameters

CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-MsBuild

Migrated from this codeplex issue

Config Transforms

Is there an easy way to do web.config/app.config transforms with Invoke-MsBuild? I have seen this article but not sure how to use that with this project. Any guidance would be awesome. Thanks!

VS 2022 support

VS changed it'ss default msbuild location on x64 from "C:\Program Files (x86)\Microsoft Visual Studio" to "C:\Program Files\Microsoft Visual Studio" (but also left old path for installer)
so Get-CommonVisualStudioDirectoryPath should also probe real VS related binaries

BuildLogDirectoryPath fails if using PathDirectory on solution in same folder

If I have my build script in the same folder as the solution and call Invoke-MSBuild with

-BuildLogDirectoryPath "PathDirectory"

an error occurs here (line 295):
if ($BuildLogDirectoryPath.Equals("PathDirectory", [System.StringComparison]::InvariantCultureIgnoreCase)) { $BuildLogDirectoryPath = [System.IO.Path]::GetDirectoryName($Path) }

As $Path do not contain a directory.

Question about releases

Github releases is currently at v2.1.0 and Posh galery at v2.2.0.

Is it possible to maintain consistency here?

I want to maintain chocolatey package up to date and would like to base it on Github releases:
https://chocolatey.org/packages/invokemsbuild

I could keep this up to date always with my bot as long as you release on both places.

If you can't keep both places up to date, please let me know here.

Registry on this system does not appear to contain the path to the Msbuild.exe directory

Hello,

I'm trying to use this plugin to build my solution but I got this error:

Get-Item : Cannot find path 'HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\140,0' because it does not exist.
At C:\Users\jlm\Documents\projects\Invoke-MsBuild\Invoke-MsBuild\Invoke-MsBuild.psm1:489 char:34
+ ... onsKeyToUse = Get-Item -Path $registryPathToMsBuildToolsLatestVersion
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (HKLM:\SOFTWARE\...sVersions\140,0:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Invoke-MsBuild : Unexpected error occurred while building "C:\Users\jlm\Documents\projects\ccc.sln": The registry on this system does not appear to contain the path to the MsBuild.exe directory.

I understand that I miss a registry but where, how ?

I'm on Windows 10 x64 with VS 2015 installed

My regedit into HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0:

http://hpics.li/f544a5b

Best regards,

Invoke-MsBuild used with powershell and octopus

Hello,

We are currently trying your Invoke-MsBuild in combination with powershell and octopusdeploy. This is currently working great but we don't get the rolling output of the msbuild in our octopus overview. This is even not happening when we are trying to build in powershell. Are we missing a parameter?

==> $buildResult = Invoke-MsBuild -Path $deployloc -BuildLogDirectoryPath c:\temp\ -MsBuildParameters "/target:deploy /property:Database=test;server=test /v:d"

Relative path in Target/ItemGroup/Content

Hello,

I try to make this part from my .csproj working:

<Target Name="CustomPostAfterBuild" AfterTargets="AfterBuild">
    <Exec Command="echo Post-Build event: Active configuration is: $(ConfigurationName)" />
    <PropertyGroup>
        <EmptyCheck>Scripts\dist\*.js</EmptyCheck>
    </PropertyGroup>
    <Error Condition="'@(EmptyCheck)' == ''" Text="Empty folder $(EmptyCheck)" />
    <ItemGroup>
      <!-- what ever is in the build folder should be included in the project -->
      <Content Include="Scripts\dist\*.js" />
      <!--<Content Include="$(MSBuildThisFileDirectory)Scripts\dist\*.js" />-->
    </ItemGroup>
  </Target>

When I publish my project from visual studio it is ok.
But when I use Invoke-MsBuild from my powershell script it fails.

I got the same problem with my Gulp task but I fixed it by using absolute path.

It's not possible for ItemGroup/Content

Is it a way for command line Invoke-MsBuild to be based on current project publishing ?

Allow for 32bit version of msbuild.exe

Hi,

Love this module!!

Please could you add the ability to supply a switch -Use32bit to facilitate the ability to use 32 bit msbuild (by default it's 64bit).
This affects msbuild processes that make use of modules like InstallShield, or old VB6

Code modification in function Get-MsBuildPath
For 32Bit, the following registry key should be interrogated
HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\

For 64Bit, the current default is all good
HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\

For our project we have made this modification, but we would love it to be part of the base code, allowing us to update our process with "newer / bug fix" versions of Invoke-MsBuild.

This issue was migrated from this codeplex issue

Hangs sometimes

Sometimes (sadly not reproduktiv) Invoke-MsBuild hangs, so I need to use Start-Job with Timeout.

$slns = gci 'C:\DEV' -Recurse -Filter *.sln
foreach ($sln in $slns)
{
    $result = $null;
    $job = Start-Job -InitializationScript { Import-Module -Name 'Invoke-MsBuild.psm1'} -ScriptBlock {
         Invoke-MsBuild -Path $args[0]  -BuildLogDirectoryPath $args[1]  -MsBuildParameters "/target:Clean;Build" -WarningAction silentlyContinue
    } -ArgumentList  @($sln.FullName, $logFolder) | Wait-Job -Timeout 100

    $result = $job | Receive-Job 

    if ($result.BuildSucceeded)
    {
        Write-Host ("Build was OK ({0})" -f $sln.FullName) -ForegroundColor Green
    }else
    {
        Write-Host ("Build was NOT OK ({0})" -f $sln.FullName) -ForegroundColor Red
        $errorOccur = $true;
    }
}

Project.sln.msbuild.log and Project.sln.msbulid.errors.log are not deleted.

Finishes with BuildSucceeded=False, even though msbuild only encounters warnings

With MSbuild version: 4.6.1590.0
Running Visual Studio 2017
The solution I am building is predominantly VB.NET code.

MsBuild only reports 86 Warnings(s) and 0 Errors(s), however Invoke-MsBuild finishes with a BuildSucceeded=False. I've isolated this to the return code of MsBuild not being equal to 0. Because if I remove that check condition ( $result.MsBuildProcess.ExitCode -eq 0) from line 441 in the script, then BuildSucceeded=True. That means that the string "Build FAILED" is not in the build output.

I've tried digging into the MsBuild docs to see if BC warnings (from vbc) are handled differently than that C# warnings. I've got a suspicion they are, but cannot confirm.

[nearly-closing] Invoke-MsBuild does not exit?

Hello, we are using Invoke-MsBuild to automate projects compilation, so that we can build libraries and then a native NuGet package all from command line (maybe on a build machine, later).

We call Invoke-MsBuild from a powershell script that cycles on configurations, platform, toolset we need (all of them read from an XML configuration file that is per-project).

Testing all of this on several machines gives sometimes strange behaviors: in fact it seems that Invoke-MsBuild never ends, and the invoker powershell script hangs waiting an output that never comes.

This seems to happen especially when changing from a build configuration to a different configuration or platform (i.e. from Debug to Release, or from Win32 to x64).

Is anybody experiencing such problem? I also tried to use the /p:UseSharedConfiguration=false workaround suggested on your blog but it seems not to help.

Thanks in advance,
Stefano

Update 1
I left my build machine alone awaiting for the command to terminate and I can confirm that after a delay of about 10 minutes, the build process succesfully exits. I double checked and the UseSharedConfiguration workaround is correctly applied, but it doesn't work.

Would be really nice to change log verbosity

Currently the log file will always be defined as:
/fileLoggerParameters:LogFile=""$buildLogFilePath""

Whereas I would like to be able to set the verbosity:
/flp1:"logfile=msbuild.log;Verbosity=Normal;Append;"

Feature Request: Support on Linux/Mac (through dotnet msbuild?)

Currently Invoke-MsBuild seems to only support running from Windows.

However, with dotnet (msbuild)/powershell being crossplatform, it would be nice if Invoke-MsBuild would also work cross platform (e.g. through dotnet msbuild).

With Invoke-MsBuild '2.6.2' running on WSL Ubuntu 18.04 LTS I get:

Get-ChildItem: .... Invoke-MsBuild.psm1:674
Line |
674 | โ€ฆ nsStrings = Get-ChildItem -Path $registryPathToMsBuildToolsVersions | โ€ฆ
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find drive. A drive with the name 'HKLM' does not exist.

Convert to double returns wrong value, because of current culture.

If the current culture is 'de-DE' for example, the conversion results in wrong values.
For example: Found version string "14.0" will be converted to 140 which could not be found.
Adding [System.Threading.Thread]::CurrentThread.CurrentCulture = 'en-US' before conversion calls or for the whole script solves the problem.

$msBuildToolsVersionsStrings | ForEach-Object {$msBuildToolsVersions.Add($_ -as [double], $_)}

The module only works on 64-bit platforms

Hi, I found another bug in this otherwise great module. ;-) When running Invoke-MSBuild on a 32-bit Windows, I get this exception:

Get-Item : Cannot find path 'Env:\ProgramFiles(x86)' because it does not exist. At C:\...\Invoke-MsBuild.psm1:674 char:36
Yes, I know that 32-bit build machines are not very common these days...

Invoke-MsBuild cannot find MSBuild when installing with Install-Module

I don't know how to properly write this ticket but when installing Invoke-MsBuild 2.7.1 using Install-Module -Name Invoke-MsBuild I'm unable to build my project (with tracing turned on it looks like it doesn't even start searching for 64bit VS Code 2022, only x86). I checked the installed version and it's correct:

PS C:\Users\UserName > Get-InstalledModule

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
2.7.1      Invoke-MsBuild                      PSGallery            Executes the MSBuild.exe tool against the specif...
2.3.0      7Zip4Powershell                     PSGallery            Powershell module for creating and extracting 7-...

However, when using Import-Module -Name "C:\PathTo\Invoke-MsBuild.psm1 it works fine (for the sessions duration)! I changed my script to use the local psm1 file now instead, but I don't understand why the normal Module doesn't work, as it should be the same thing?

typo in errors log file name

build-log: "<projectfileName>.msbuild.log"
error-log: "<projectfileName>.msbulid.errors.log"

invoke-msbuild version 2.6.0

Can't create/find build log normally, hangs bypassing devtools

When I use this it can never seem to create the build log. If I add the parameter to bypass dev tools it seems to build and generate a log but no output is shown and it seems to hang even though the build finished. Windows 10, PowerShell 5, VS 2017 Enterprise.

C:\source\cbsnorthstar

[Feature/CheckSearchServerTime]> Invoke-MSBuild NorthStar.OrderEntry.POS.sln
WARNING: Cannot find the build log file at
'C:\Users\geoffh\AppData\Local\Temp\NorthStar.OrderEntry.POS.sln.msbuild.log', so unable to determine >if build
succeeded or not.

Name Value


Message Cannot find the build log file at 'C:\Users\geoffh\AppData\Local\Temp\NorthStar.Order...
MsBuildProcess
BuildLogFilePath C:\Users\geoffh\AppData\Local\Temp\NorthStar.OrderEntry.POS.sln.msbuild.log
BuildErrorsLogFilePath >C:\Users\geoffh\AppData\Local\Temp\NorthStar.OrderEntry.POS.sln.msbulid.errors.log
BuildSucceeded
ItemToBuildFilePath NorthStar.OrderEntry.POS.sln
CommandUsedToBuild cmd.exe /k " "C:\Program Files (x86)\Microsoft Visual >Studio\2017\Enterprise\Common7...
BuildDuration 00:00:04.0651079

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.