PowerShell CmdLet as Visual Studio External Tool - visual-studio-2010

I am attempting to add a PowerShell cmdlet as an external tool in Visual Studio 2010, but whenever I call the external tool I get:
{foo} cannot be loaded because the
execution of scripts is disabled on
this system. Please see "get-help
about_signing" for more details.
I have already set my system's execution policy to 'RemoteSigned' (I also tried 'Bypass'), so why is this happening? I am fully able to run that same script if I open up a command line and call it via powershell.exe path\to\script.ps1 (which is exactly what my external tool definition is calling).

Are you running on a x64 system? If so, you have to set the execution for both x86 and x64 PowerShell. You can also pass the ExecutionPolicy directly as a parameter to Powershell (2.0) via the command line:
powershell.exe -ExecutionPolicy RemoteSigned -Command "&{ foo }"

Related

powershell execution policy change issue

i cannot run my project file scripts in visual studio because of this policy
its not even changing to REmoteSigned even for that command am getting same error.

Installing Debugging Tools for Windows from command line

I am trying to automate a Windows build in AWS Codebuild which require downloading Windows SDK with Debugging Tools for Windows installed.
I am able to install the Windows SDK using Visual Studio with some other files required.
powershell -c "Start-Process -FilePath 'vs_community.exe' -ArgumentList \"--quiet\",
\"--norestart\" , \"--add Microsoft.VisualStudio.Workload.Universal\",
\"--add Microsoft.VisualStudio.Workload.NativeDesktop\",
\"--add Microsoft.VisualStudio.Component.VC.ATLMFC\",
\"--add Microsoft.VisualStudio.Component.Windows10SDK.19041\",
\"--includeRecommended\" -Wait;"
The build requires Debugging Tools for Windows enabled in Windows SDK which is straightforward in UI installation. But since I want to automate this, I am looking for a command line option to install Debugging Tools for Windows in Windows 10 SDK.
I was able to install Debugging Tools for Windows via standalone windows sdk installer through command line as below:
powershell -c "Invoke-WebRequest -Uri 'https://go.microsoft.com/fwlink/?linkid=2120843' -OutFile winsdksetup.exe -UseBasicParsing ;"
winsdksetup.exe /features + /q /norestart
/features + selects all the features available in Windows SDK to install.

run vcvarsall, but cl and other still unavailable

As titled, using Powershell after executing
PS C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build> .\vcvarsall.bat amd64
then programs like cl, nmake or msbuild should be available on the path, but they are not
PS C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build> cl
cl : The term 'cl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
cl
~~
CategoryInfo : ObjectNotFound: (cl:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
Specs:
VS 2019 Community Edition with the "Desktop development with C++" workload:
MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.28)
Windows 10 SDK (10.0.18362.0)
Just-In-Time debugger
C++ profiling tools
C++ CMake tools for Windows
C++ ATL for latest v142 build tools (x86 & x64)
Test Adapter for Boost.Test
Test Adapter for Google Test
Live Share
C++ AddressSanitizer (Experimental)
Win10 Pro N x64, 20H2, 19042.746
What am I missing?
Powershell executes the batch file in a child cmd process. The VS environment is set in that cmd process, then gets discarded when the process ends and control returns to Powershell.
The straightforward solution is to reverse the sequence, and set the VS environment before starting the Powershell session so that PS inherits it. Assuming a usual VS installation with the correct VS160COMNTOOLS environment variable set, this can be done by running the following at either a command prompt, via Start / Run, or from PS itself.
cmd /c ""%VS160COMNTOOLS%\..\..\VC\Auxiliary\Build\vcVarsAll.bat" amd64 && start powershell"
See also In a CMD batch file, can I determine if it was run from powershell? and How can I use PowerShell with the Visual Studio Command Prompt? for more discussion and possible alternatives - both for returning environment variables from batch files to PS in general, and for the VS environment in particular.

How to install Visual Studio Remote Tools on Server Core?

I'd like to install the Visual Studio 2013 Update 4 Remote Tools on a Windows 2012R2 Server running IIS 8.5. This is a pretty simple process outlined here: https://msdn.microsoft.com/en-us/library/bt727f1t.aspx
The problem I have is that the server I'm trying to installing this on is a Server Core, meaning, there is no GUI. The Remote Tools application is an exe that only installs via GUI.
I've tried to install it with PowerShell and it just hangs. I'm also not able to find the Remote Tools in Web Platform Installer to install it that way. Extensive Googling has turned up nothing.
Does anyone know how to install the Visual Studio Remote Tools on a Server Core so that I can debug on my DEV server? Any advice is appreciated.
Create a .bat file and enter the below. (not PowerShell) (Or just at the command line.)
rtools_setup_x64.exe" /install /quiet
word...
You don't have to install remote tools. Just copy msvsmon.exe, from your local Visual Studio installation. Then start it from remote powershell silently:
Start-Process -FilePath .\msvsmon.exe -ArgumentList '/nosecuritywarn /port:4022 /silent' -Verb runAs
Don't forget to open firewall port.
Turns out that you can simply remote into the Core server. When you do so, you'll get a command prompt only. From there, CD to the directory where the remote tools install file is. Execute the file by typing the file name at the command prompt, ie: rtools_setup_x64.exe.
This will run the installer, with a GUI, on the Core server. Its that simple, I didn't think you'd be able to get the install wizard on a Core server, however you do.

Failure adding assembly to the cache Windows XP SP3

i am trying to add an assembly to the GAC but the error indicates that "Failure adding assembly to the cache: Administrator permissions are needed to use the selected options. Use an administrator ommand prompt to complete these tasks."
I am using Windows XP SP3 and user account type is Administrator. Please refer to the image below.
TIA
http://i.stack.imgur.com/TZXpc.png
You are administrator on your machine but you don't run the visual studio command prompt (or cmd.exe) as an admin ...
I was able to solve my problem by additional commands via command prompt
C:\WINDOWS\system32>runas /user:computerName\administrator cmd

Resources