wrote a simple code by powershell
I am creating a file xml with some program settings
I want to run it before build desktop software
Get this error exited with code 1
in Visual Studio pre build event
powershell.exe $(ProjectDir)Script1.ps1
I thought it was from the wrong code. I simplified the code. However I get the same error
write-Host 'test'
exit 0
How can I solve this problem?
Related
We are using Visual Studio 2019 and TFS server 2015.
TFS build is giving below error:
Error: The active Test Run was aborted because the execution process exited unexpectedly. The test execution process crashed while running the tests. To investigate further, open file:///C:/Users/username/AppData/Local/CrashDumps/TE.ProcessHost.Managed.exe.11108.dmp file in Visual Studio and choose "Debug in mixed mode".
##[error]VSTest Test Run failed with exit code: 1
##[error] at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeVSTestCmdlet.ProcessRecord()
##[error] at System.Management.Automation.CommandProcessor.ProcessRecord()
If we uncheck Code coverage enable checkbox, then build gets successful, its failing when we enable that check box.
Observation: Recently on server, Visual Studio Build Tools 2022 (17.2.5) got updated. After that TFS builds not working.
Please someone help to solve this issue.
I know my question is very similar to this one (Visual Studio Package Installation Error: "Failed to initialize the PowerShell host."). But still the answer that was given there didn't solve my issue.
So like the guy in the link above I have a problem in Visual Studio when I try to create a Web Forms Application or when I want to download and install some Nuget packages (example: AWS DynamoDB sdk) it gives me this error:
failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.
When I did some browsing I came across this command:
Set-ExecutionPolicy Unrestricted
But that didn't help. I still got the error. In the link above someone shares this command:
start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job
But I don't really know what difference it makes or what it actually does. After trying the first command and doing:
Get-ExecutionPolicy
I got a response that the value is Unrestricted. But in the other command it was still AllSigned. I also tried running Visual Studio as administrator and that didn't help either.
I figured out, that there was a certificate from Microsoft on the Untrusted list, and I needed to delete it, and now it works.
When I create a new WebAPI project (MVC4) I get the following error.
EntityFramework.5.0.0: Failed to initialize the Powershell host. If your powershell execution policy setting is set to AllSigned, open the package manager console to initialize the host first.
jQuery.1.7.1.1: Failed to initialize the Powershell host. If your powershell execution policy setting is set to AllSigned, open the package manager console to initialize the host first.
After Googling I have found a few answers but nothing that works yet.
Error creating new MVC project - EF and JQuery
This answer seems like it should work for me as my last project was a 7z Command Line app and I might have done something daft with 7zip. But I copy pasted the 7-Zip directory from Program Files to Program Files (86) with no luck.
http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/c934fed4-e44e-4a06-9e3b-eccb9c8aa8d6
There is an answer here that might work (I haven't tried it) but even if it does work I wouldnt want to do this every time I create a new project.
Is anyone able to help me with this one?
I got around a similar error by running PowerShell as administrator with the command Set-ExecutionPolicy Unrestricted, restarting Visual Studio, and opening the Package Manager Console before what I wanted to do.
Make sure you understand the security implications of doing this first.
http://technet.microsoft.com/en-us/library/ee176961.aspx
Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode.
AllSigned - Only scripts signed by a trusted publisher can be run.
RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run.
Unrestricted - No restrictions; all Windows PowerShell scripts can be run.
I encountered this issue recently, after re-install VS and install the latest VS update 2, things go well. This works for me at least.
I have a SQL Server 2008 Database Project that I'm attempting to deploy using Visual Studio 2010. When I click deploy, the build works fine, but after it creates the deployment script and begins to execute it, I get the following errors:
Error 8 SQL80001: 'DatabaseName' is not a recognized option.
Error 7 SQL80001: Incorrect syntax near ':'.
Looking at the deployment script, it has the following lines:
:setvar DatabaseName "DEV_DB"
...
GO
:on error exit
So it looks like SQL Server is not running the deployment script in SQLCMD mode to understand that syntax. If I'm copying and pasting into SSMS, I can set that option, but I want to deploy straight from Visual Studio. Where is the setting to have VS run this script in SQLCMD mode OR How can I set the script to not generate using SQLCMD syntax?
Thanks.
I am looking to improve my personal development process. I would like to create a batch file or similar that I can run from Windows PowerShell or the plain-old command line that does the following:
Compiles my solution (e.g. C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /m:8 "%CD%\MySolution.sln")
If the compilation was successful, run it in debug mode, attaching the visual studio debugger, otherwise stop.
In essence, I am trying to replicate the behavior of pressing F5 in Visual Studio, but invoked from the command line. Is this possible? The reason for all this, is that I find the VS UI responsiveness degrades significantly when invoking MSBuild commands from within the IDE.
msbuild
if($?) {
# launch your process
Debug-Process -name "<Your Process Name>"
}