I have some PS scripts that I use for SVN tagging / releasing applications.
Usually its working fine, everything is built as I want to.
Few days ago, I'm told to make a fresh release of some older application.
So I tried leveraging my scripts for that purpose. So far so good.
The problem I'm facing now: Somehow, when MSBuild is called inside my script, its giving me errors
The thing is, when I execute the same command outside the script in a PS console, its building without errors.
The call: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\msbuild.exe solution.sln /t:Build /p:Configuration=Release /m /v:q /clp:Summary /nologo
Any suggestions are appreciated.
Apparently it has to do with PackageReference on older projects..
https://github.com/dotnet/sdk/issues/8100 my workaround is to build in VS first then use my script without restore or clean.
So I got my release.
Related
Currenlty I am using Visual Studio community edition and Gtest.
When I run my test using the Visual Studio debug, my test are running fine
But when I build the solution and run my test fail.
Is there a way I can pass the PATH environment to the command I am runnig?
Try to set the PATH on powershell so it would load while running the command.
Thanks to #273k I was able to solve my problem.
The reason this test did not pass on the command line, was due to this was being run on a different folder.
Once I moved the relevant support files in the same folder the test started to pass
Not sure how to do this... I work mostly on OSX and linux systems, so when I install an app or use for example G++ or xcodebuild, I just call it from terminal.
On Windows, I did install msbuild with VS2015, but if I am in powershell or regular command prompt, typing msbuild result in an error. I have to specify the whole path to make it work.
What is the equivalent in Windows world, of setting console so when I type msbuild, it gets the correct path?
You can set your path like so in:
PowerShell
$Env:Path = "<Path_to_msbuild>;${Env:Path}"
Batch/Cmd
set "PATH=<Path_to_msbuild>;%PATH%"
Note: The <path_to_msbuild> is the folder where msbuild.exe exists, and NOT the direct path to the executable itself
How it works
This will add the msbuild binary to your path, so you can invoke it from anywhere!
To verify which location msbuild is running from you can simply run (in both languages!):
where.exe msbuild
If you create just a link to msbuild you still won't be able to call for example the compiler from the command line. Which is why VS provides a convenient (pretty much canonical) way to do this by supplying a batch file which sets up the PATH and all the other build-related environment variables.
Example if you are on cmd.exe:
> "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
> msbuild
Microsoft (R) Build Engine version 14.0.25420.1
...
> cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86
...
You can invoke this from the Start menu as well: hit start, type pro vs to look for matches, select Developer Command Prompt for VS2015.
For PowerShell (which I'd recommend spending time on instead of cmd) you'll need an extra function like presented here: https://stackoverflow.com/a/21652729/128384
I am using VSCode version 1.12.2 in Windows 10 x64 build 16193. I am trying to debug Powershell in VSCode, but I cannot get the PowerShell Integrated Terminal working. Every time I started the terminal, here's what I see:
And then it hangs in that stage. I can still debug, start, step in, step out..., but I cannot view my variable or run any expression.
My VSCode is using powershell x64 here:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
So this is a known issue with this version of windows 10. Workaround here: https://github.com/PowerShell/vscode-powershell/issues/742
It's possible it's getting stuck on something while loading your profile(s). Try adding this to your settings to skip this:
"powershell.enableProfileLoading": false
I have had a similar problem, it seems. I cannot be sure it is the same, but when I would "load a file with VSCode" (user installer confirmed, system installer unconfirmed), it would hang. The following avenues tested:
Double-clicking on a PS1 file (the association to Code being made)
Starting VsCode empty and then loading the file
Starting VsCode from the command-line with a file-designation parameter
Using the --verbose switch, I got a listing which lead me to believe that VsCode seemed to be checking on updates using NPM (I could be wrong here).
Whatever the underlying problem, I did a lot of prodding and probing, and the cure I found was this.
Delete the directory called C:\Users\YourUserId\.vscode.
This directory is rather large, is not wiped by software removal, and may be corrupted apparently. After deleting it, the problem disappeared.
I have setup a build definition in Visual Studio Team Services (was Visual Studio Online) builds.
Below is a snapshot of Powershell script setup:
I haven't set anything in 'Working folder' as I am assuming that it defaults to the folder where the script lives as specified in the info.
When build runs, it throws an exception at the Powershell step.
Below is the error snapshot:
Somehow the working folder is not the folder where the script is located.
Any suggestions to fix it?
Use the powershell variable $PSScriptRoot to get the directory where your script is, and use that to figure out all other paths.
I started down this path of wanting to do code analysis on my solution using msbuild. I was looking at FxCop but it appears to now be part of Visual Studio and from my understanding you need Visual Studio installed on your build agents.
I am calling msbuild from a powershell using the following command;
"$(get-content env:systemroot)\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /tv:4.0 /p:RunCodeAnalysis=Always"
It appears to run the code analysis and output warnings but never fails the build, even after I added <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
to my .csproj file.
All I want is to run code analysis from msbuild command line and have it fail the build if any warning is found. I understand it can be done in Visual Studio but I need to be able to run this from the command line (with/without VS2013)
Am I missing something? Shouldn't /p:RunCodeAnalysis=Always and setting the CodeAnalysisTreatWarningsAsErrors to true be all that is needed?