Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add microsoft/msbuild image #492

Merged
merged 1 commit into from
Dec 8, 2016

Conversation

StefanScherer
Copy link
Contributor

@StefanScherer StefanScherer commented Nov 20, 2016

Here is a Dockerfile to build a Docker image with the Visual Studio C++ Build tools installed.
It would be great if we have something like FROM microsoft/vcbuildtools:14.3 to run msbuild in a Container very easily.

How to use this image

Build the image

docker build -t microsoft/vcbuildtools:14.3 .

Use the image

Go into a folder with a simple C++ or other project with a solution file *.sln.

docker run -v "$(pwd):C:\code" microsoft/vcbuildtools:14.3 msbuild yourproject.sln /p:Configuration=Release

Example:

git clone https://github.com/StefanScherer/win-getaddrinfo
cd win-getaddrinfo
docker run -v "$(pwd):C:\code" microsoft/vcbuildtools:14.3 msbuild getaddrinfo.sln /p:Configuration=Release
dir getaddrinfo.exe


WORKDIR /code

ENTRYPOINT ["C:\\entrypoint.bat"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lost and found. Perhaps instead of using this entrypoint.bat we should burn in all environments as done here: https://github.com/friism/hello-world/blob/32b486472ebcd64fd26b0264dc988958bf44ccf5/windows/Dockerfile.build#L14-L19

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the c++ toolchain really likes to be run in cmd and users are used to interacting with it using the "Visual Studio developer prompt", then I think sticking to cmd is good. But it also seems like MS is moving towards Powershell: http://news.softpedia.com/news/microsoft-replaces-command-prompt-with-powershell-in-latest-windows-10-build-510328.shtml

Copy link
Contributor Author

@StefanScherer StefanScherer Nov 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I also prefer your solution setting all environment variables. I found the problem with some of the variables. If a value ends with a backslash \ then it is stored with a double quote " instead. Eg. for the environment variable WindowsSdkDir.

Replacing the

setx /M $v[0] $v[1]

command with

[Environment]::SetEnvironmentVariable($v[0], $v[1], [EnvironmentVariableTarget]::Machine);

it works fine. I'll update this PR to get rid of the entrypoint.bat.

@StefanScherer
Copy link
Contributor Author

Removed the entryoint.bat script.

@PatrickLang PatrickLang self-assigned this Nov 28, 2016
# msbuild

Build a Docker image with Visual C++ Build tools.
The `entrypoint.bat` script calls the `vcbuildtools.bat` script to set all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see those scripts. Are they still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entrypoint is no longer needed, I'll update the readme.

@PatrickLang
Copy link
Contributor

Thanks for submitting this! I'm trying to see if anyone from the MSBuild team wants to review it. It looks good to me, so if they don't have any feedback I'll get it merged.

@StefanScherer
Copy link
Contributor Author

Updated the README.md.

Copy link

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[I'm an MSBuild maintainer]

We don't currently have a Docker image, nor plans to create one, though @alexellis proposed one: dotnet/msbuild#1140.

Since this isn't just MSBuild I'd rather the name be something like vcbuildtools.

C# builds are likely to fail without some .NET Targeting Packs installed. Since you're aiming at C++ builds this might not be the place for it.


SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]

RUN (New-Object System.Net.WebClient).DownloadFile('http://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe', 'visualcppbuildtools_full.exe') ; \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the "with Update 3" installer, right? (It appears to be, just double-checking.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StefanScherer why not just use Invoke-WebRequest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@friism After changing the SHELL line to

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

I can switch back to Invoke-WebRequest to have the same download rate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you have another commit with that change? I want to get this merged but wasn't sure if you were going to switch back to Invoke-WebRequest or not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder. Updating right now and testing the build again...

## Build image

```
docker build -t msbuild .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a version? vcbuildtools:14.3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

@PatrickLang
Copy link
Contributor

Thanks @rainersigwald . I think vcbuildtools would be a better name as well.

Copy link
Contributor

@friism friism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably make clear that this is 64bit toolchain. As @rainersigwald suggested, it might also be worth parametrizing the VS version to 14


SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]

RUN (New-Object System.Net.WebClient).DownloadFile('http://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe', 'visualcppbuildtools_full.exe') ; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StefanScherer why not just use Invoke-WebRequest

@friism
Copy link
Contributor

friism commented Nov 29, 2016

This (now obsolete) PR has details on how something like this might be used: docker-library/hello-world#22

Signed-off-by: Stefan Scherer <[email protected]>
@StefanScherer StefanScherer changed the base branch from live to master December 8, 2016 20:11
@StefanScherer
Copy link
Contributor Author

@PatrickLang Updated the PR and changed it to master branch. Can't remember why I opened this to live branch directly.

@PatrickLang
Copy link
Contributor

live branch is actually preferred now but either work. We changed the default to live.

@PatrickLang PatrickLang merged commit 0252ceb into MicrosoftDocs:master Dec 8, 2016
@rs38
Copy link
Contributor

rs38 commented Dec 13, 2016

building without testing (at least unit test level) is quite pointless in nowadays devops tool chains. :)
is anyone of you aware of an image providing mstest / vstest? (not v2).
further questions would lead me to execution of web performance tests, which is very out of scope in this issue, any idea where to place?

@StefanScherer StefanScherer deleted the add-msbuild-image branch December 14, 2016 17:13
opbld15 pushed a commit that referenced this pull request Jan 3, 2020
Added custom path option to CredSpec docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants