Is it possible to install any version of Visual Studio in a Windows Container on a Windows Server?
The motivation is to use Windows Containers for building software in continuous integration systems, so that the build environment is standardized.
Visual Studio seems to not be supported officially on Core Server, but I agree it would be really nice to be able to do this. Let's try:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell"]
RUN Invoke-WebRequest "https://aka.ms/vs/16/release/vs_community.exe" -OutFile "$env:TEMP\vs_community.exe" -UseBasicParsing
RUN & "$env:TEMP\vs_community.exe" --add Microsoft.VisualStudio.Workload.NetWeb --quiet --wait --norestart --noUpdateInstaller | Out-Default
RUN & 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe' /version
CMD ["powershell"]
(I'm pushing this image into lukaslansky/visualstudio-netwebworkload, use with caution.)
Output of the build is:
[...]
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
So this seems to work! You should play with those --add installator arguments to specify what components you need precisely for your build, they correspond to workloads and components you see in the GUI. See the documentation.
Your best bet at this point is to use Visual Studio Build Tools.
A way to install visual build chain in a windows container could be to use chocolatey package visualstudio2017buildtools.
Starting Dockerfile with something like :
FROM microsoft/windowsservercore
RUN powershell.exe -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SETX PATH "%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
RUN choco install -y visualstudio2017buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --installPath C:\BuildTools" || IF "%ERRORLEVEL%"=="3010" EXIT 0
RUN call "C:\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
Just for the record MS is not planning support VS inside containers, the best alternative that you have is MsBuild. Some months ago was possible but with the latest version from VS is not possible. Source: vsts-agents
Windows Containers do not currently include GUI apps. The limitation is on Microsoft, not on Docker.
For example try something simple like running Notepad (in Windows Server Core container). The process is launched but no GUI shows up.
I've recently spent a lot of time investigating this as our goal was to set up "dockerized" DevOps agents which were capable of running the VsBuild#1 pipeline task (among other things).
Generally, if you DON'T need VsBuild#1 (or some of the other tasks related to Visual Studio, like VsTest#2 or the like) then you're better of using https://hub.docker.com/_/microsoft-dotnet-framework-sdk/ as your base and call it a day; those images come with the Build Tools and VS Test agent already installed.
However it IS possible to install VS. Some notes:
I've had issues when installing VS on top of the images mentioned above. For some reason VS silently fails to copy some files when it detects some existing tools already being in place. As such, I recommend using the https://hub.docker.com/_/microsoft-dotnet-framework-runtime/ images as a base.
Installation must be "quiet" (since there's no GUI) and cannot request a restart.
From what I can tell VS would usually queue up some kind of pre-build process which isn't triggered when the system isn't restarted. This can be manually triggered, however, by running %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen update. Do note that with a VS installation inside Docker this WILL fail in various ways, so you'll need to find ways around this.
Check the original DockerFile for the SDK images for some references; specifically interesting is the manual installation of .NET Framework targetting packs: https://github.com/microsoft/dotnet-framework-docker/blob/main/src/sdk/4.8.1/windowsservercore-ltsc2022/Dockerfile
(Should this link ever stop working because the file is moved then it's worth taking a look at the DockerFiles in the https://github.com/microsoft/dotnet-framework-docker repo)
Not all VS components can be installed! While I haven't nailed it down to which components are troublesome, a full VS install inside Docker will likely exceed default Docker disk space limits and / or run endlessly (soft lock as some proces will wait forever for some other installation process to finish). As such it is important to carefully curate the list of VS component IDs you wish to install using --add arguments.
Related
I am trying to install Visual Studio 2019 but unfortunately every time I get this error
could not install Microsoft.NetCore.HostPath
Here is an image of the same:
Solution worked for me (nothing else helped)
Install PowerShell v7 (https://aka.ms/pscore6)
Backup original PowerShell v1 from C:\Windows\SysWOW64\WindowsPowerShell\v1.0
Copy "C:\Program Files\PowerShell\7" to C:\Windows\SysWOW64\WindowsPowerShell\v1.0
Rename pwsh.exe to powershell.exe
Now VS installer is using PowerShell v7 thinking it is v1, works fine!
So, I believe it is kid of bug in old version of PowerShell
Probably there is better way to mimic version, I just did old school brutal magic after loosing a day for that
If you have .Net 5 on your system and updating to 16.11.8 then you may face this issue. Till now only work around is to downgrade to 16.11.7.
And you may have in uninstall and then reinstall VS 2019. You can get 16.11.7 or other older version of VS from following URL:
https://learn.microsoft.com/en-us/visualstudio/releases/2019/history
Similar issue has been reported here too: Revert Visual Studio 2019 Update
Activate the PowerShell privilege's, run gpupdate then restart the machine. then reinstall the setup again.
Set powershell execution policy to unrestricted. Open privileged powershell console and type
Set-ExecutionPolicy Unrestricted
re-execute setup.
Getting Windows PowerShell access worked for me.
I was not able to install VS2019 and VS2022.
Did anyone manage to:
install Visual C++ Build Tools 2015
inside Windows container
and in a custom directory?
Whatever I do, it always installs to standard location: C:\Program Files (x86)\Microsoft Visual Studio 14.0
Below is the example Dockerfile to demonstrate that it silently ignores /CustomInstallPath parameter:
FROM microsoft/windowsservercore:ltsc2016
# download installer
ADD https://go.microsoft.com/fwlink/?LinkId=691126 visualcppbuildtools_full.exe
# install
RUN cmd /c visualcppbuildtools_full.exe /Passive /CustomInstallPath C:\BuildTools
# test
RUN dir C:\BuildTools
I've tried with microsoft/nanoserver base images too, can't install at all.
I've tried installing via Chocolatey which also allows passing /CustomInstallPath, same result.
There are some discussions where people recommend fully uninstalling VS and anything related, but here I'm using a completely standard image, so it shouldn't matter. Anyway I've tried calling /uninstall first - didn't help.
AFAIK some components of the BuildTools "package" will always go in %ProgramFiles(x86)% no matter what (i.e. the C++ compiler).
I am exploring the new Entity Framework Core (NOT in conjunction with ASP.Net, what I am coding is just a WinForms app) and found some tutorials mentioning a dotnet command line command needed to create "migrations". When I try it, however, it says 'dotnet' is not recognized as an internal or external command, operable program or batch file. I have searched my hard drive for "dotnet.exe", "dotnet.bat" and "dotnet.cmd" but have found nothing. I use Visual Studio 2015 Community Edition. Where do I find this command executable? What am I to add to the %PATH% environment variable for it to work?
dotnet.exe is located in
C:\Program Files\dotnet>
If you are using command prompt and getting message that 'dotnet' is not recognized as an internal or external command, operable program or batch file" then first check the above path. If you found the above path then just copy it and set it as an environment variable of your PC.
Steps:
Open control panel>System and Security>System
Click on Advanced system settings
In advanced section, click in Environment Variables
In System variables, select path and edit
After semicolon, write "C:\Program Files\dotnet"
Click on Ok button till end.
now to check whether its working on not. Just open command propmpt and type
dotnet --version
This will show the dotnet version installed in your PC.
I've just found the answer myself. It seems like the dotnettool does not get installed with Visual Studio. Installing .NET Core tools preview for Visual Studio (direct link to the .NET Core 1.0.1 tools Preview 2: DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe) resolved the problem by adding %ProgramFiles%\dotnet\dotnet.exe.
I have faced another problem after this, however: the dotnet tool running but saying No executable found matching command "dotnet-ef" but this is a matter of another question. I will, however, share the solution here once I find it.
UPDATE:
As promised, here are the question and the answer about the thext problem I have faced (the No executable found matching command "dotnet-ef" error).
And here is the solution for the next one (the ... violates the constraint of type 'TContext' error)
For me it is located at C:\Program Files\dotnet
You need to install .NET SDK separately. You can download and install from https://download.microsoft.com/download/1/1/5/115B762D-2B41-4AF3-9A63-92D9680B9409/dotnet-sdk-2.1.4-win-gs-x64.exe
More details : https://www.microsoft.com/net/learn/get-started/windows
Also I did not have to set up path variable. After running above installation dotnet was automatically added in path. Just open a new cmd and run -
C:\Users\anike>dotnet --version
2.1.4
I have the same issue on windows 10 64bit after installing dotnet core SDK 3.1
To resolve it, I defined the environnement variables path for .netcore 3.1 and restarted my machine.
Download and install .NET core from https://dotnet.microsoft.com/download/dotnet-core, open a new prompt once it's installed.
dotnet
You will get the following message if installation is successful. The path where dotnet.exe is will be added to PATH as part of the installation.
Usage: dotnet [options]
Usage: dotnet [path-to-application]
Options:
-h|--help Display help.
--info Display .NET Core information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.
path-to-application:
The path to an application .dll file to execute.
If you're using .NET Framework 4.x and WinForms, you probably don't want to use the .NET Core tools (i.e. dotnet ef). Instead, install the Microsoft.EntityFrameworkCore.Tools package and use the NuGet Package Manager Console (or PMC) PowerShell cmdlets: Add-Migration, Update-Database, etc.
To future readers
If on Windows check if you have multiple installations of dotnet on Program Files and Program Files (x86) or Program Files(x32). win + R open cmd, type
where.exe dotnet
only Program Files should have dotnet. Restart Visual Studio .
I had the following error in Visual Studio when first installed .net sdk. I finally just closed VS code, reopened VS Code, and it worked fine.
'dotnet' is not recognized as an internal or external command, operable program or batch file
For windows the reason was that it need to run from a Command prompt outside from visual studio.
execute this command in command prompt,
dotnet run
then application run in https://localhost:5001
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.
I seem to be unable to install a build agent on our TeamCity 5.1.2 build server that is compatible with a VS2010 (sln) build configuration.
Under "Build Runners", the following runners are listed:
Ant: Runner for Ant build.xml files
Duplicates finder (.NET): C# and VB duplicate code finder
Command Line: Simple command execution
And under "Compatible configurations", the project I've configured to build with the Visual Studio 2010 (sln) build runner is listed under "Incompatible configurations".
To install the build agent, I'm simply running the .msi installation package, but it seems the default settings are not good enough. The build server machine has Visual Web Developer Express 2010 as well as .NET versions 2.0-4.0 installed, but no full version of VS. Do I need anything more?
(I have no experience whatsoever of building with msbuild scripts, so if I can I want to avoid having to do that.)
I think I figured it out:
Install the Windows SDK from Microsoft. Right now, the latest version is 7.1.
Note that since I just suddenly noticed that it worked, I don't know for certain that this is what did it - it might me completely irrelevant, but this is the only thing in my configuration I changed that I think could be relevant.
TeamCity build agent does not detect .NET 4.0 Client Profile as dotNetFramework4.0. Check you have full .NET Framework 4.0 installed.
Another reason of that is build agent has corrupted plugins. To fix it:
- stop agent
- remove /plugins, /system, /tools folders
- start agent
- wait till agent autoupgrade (agent service may be shown as stopped, just wait)