为什么我不应该在 CI 服务器上安装 Visual Studio?

发布于 2024-09-10 14:37:25 字数 225 浏览 6 评论 0原文

许多刚接触 CI(持续集成)的人在他们的 CI 服务器上安装 VS(Visual Studio),“因为需要它来编译代码”。 MSTest 是这里提到的一个常见参考。

为什么我不应该在 CI 服务器上安装 VS(或者一般来说,任何非开箱即用的软件)?

(这个问题显然之前没有被问过,所以我添加它以供参考。如果它已经存在,抱歉,我错过了它,请合并。如果一段时间内没有对此问题提供答案,我可以自己添加一个)

A lot of people new to CI (Continuous Integration) install VS (Visual Studio) on their CI server "because it is required to compile the code". MSTest is a common reference brought up here.

Why should I not install VS (or generally speaking, any software not out-of-the-box) on my CI server?

(This question has not been asked before apparently, so I'm adding it for reference. If it already exists, sorry, I missed it, please merge. If no answer is provided to this question within some time I can add one myself)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沉溺在你眼里的海 2024-09-17 14:37:25

因为你不需要。 Visual Studio 许可证非常昂贵,因此将一个许可证放在无人使用的服务器上只是一种浪费。有几个论点解释了为什么您仍然需要在持续集成上安装完整的 Visual Studio 实例服务器 - 但这里是他们的反驳论点:

原因 1:我需要它来编译。
现实:不,你不知道。您需要 MSBuild 来编译,但这是 在 Windows SDK 中免费提供。请注意,不同的操作系统和 .NET 版本有多个版本,因此请小心下载正确的版本。

原因 2:我需要它在服务器上进行快速修复。
现实:不,你不知道。您不应该在服务器上进行快速修复 - 您应该从版本控制系统中签出,进行修复,在本地构建和运行测试,直到它正常工作,签入并让 CI 系统执行此操作剩下的给你。 这就是您拥有 CI 系统的原因。

原因 3:如果没有 Visual Studio,我无法在 CI 服务器上运行 MSTest。
现实:错误。 AFAIK,MSTest 运行器也是 SDK 的一部分(至少在我们的 CI 服务器上看起来是这样的 - 尽管我无法验证它,因为我们目前没有任何测试......)。然而,快速谷歌搜索发现这篇博客文章解释了如何做到这一点也没有 SDK。我还没有详细阅读它,所以我不能保证它有效,或者它是合法的。你已被警告过。

欢迎在评论中添加更多理由,我会予以反驳。

Because you don't need to. A Visual Studio license is pretty expensive, so having one just lying around on a server where no one's using it is just a waste.There are a couple of arguments why you would still need to install a full blown Visual Studio instance on your Continuous Integration server - but here are their counter arguments:

Reason 1: I need it to compile.
Reality: No, you don't. You need MSBuild to compile, but that is available for free, in the Windows SDK. Note that there are several versions for different operative systems and .NET versions, so be careful to download the correct one.

Reason 2: I need it to make quick fixes on the server.
Reality: No, you don't. You shouldn't make quick fixes on the server - you should check out from your version control system, make the fix, build and run tests locally until it works, check in, and have the CI system do the rest for you. That's why you have a CI system.

Reason 3: Without Visual Studio, I can't run MSTest no my CI server.
Reality: Wrong. AFAIK, the MSTest runner is also part of the SDK (at least that's what it seems like on our CI server here - although I can't verify it since we don't have any tests at the moment...). However, a quick googling found this blog post which explains how to do it without the SDK as well. I haven't read through it in detail, so I can't promise that it works, or that it's legal. You have been warned.

Feel free to add more reasons in comments, and I'll counter them.

转身泪倾城 2024-09-17 14:37:25

无论如何,您可能需要安装 Visual Studio,出于实用性,

我打算尝试反驳 @TomasLycken 在评论中发布的已接受答案,但发现我需要更多空间来讨论。尽管我在技术上同意 @TomasLycken 的主张,但在这里,我将列出一些我发现很难在 CI 服务器上安装的依赖项 - 并让您来决定接受的答案有多正确......

< strong>1 - 'mshtml'主互操作程序集

您可以在这个SO问题中看到我在构建输出中遇到的问题 我创建并回答了。请注意,我花了几个小时弄清楚如何注册所需的 PIA - 这是在服务器上运行来自我的 V.Studio 安装的一些 .exe 的结果 - 嗯嗯嗯

上下文: 我有一个使用 Web 浏览器控件的 win 表单项目。在“WebDocumentCompleted”事件中,我将 DomDocument 转换为 hshtml.IHTMLDocument2 ..这就是为什么我在我的项目中引用了 Microsoft.mshtml

结果:现在 @TomasLycken 建议我通过修复代码来解决这个问题。起初,我想对这个建议感到犹豫。我的代码已部署并正在运行!但是,当我进行网络搜索时,我发现 Microsoft 并不真正建议使用他们的mshtml PIA 在其开发的 Visual Studio 环境之外

这 10 行令人反感的代码实际上是代表我们的用户进行了一些屏幕抓取数据,这些用户在几个知名门户网站上对技术主题进行研究。但是,当我测试这段 2009 年编写的代码时,它曾经操作的 DOM 现在似乎在 2016 年发生了变化。我知道令人震惊。可能不是我最聪明的代码。也许是时候退役这个函数了 - 换句话说,修复代码并重新提交

@TomasLyken 我认为这一点是正确的。

2 - Win Forms 项目构建后脚本

上下文:所以我遇到了这个SO 上的酷后期构建技术 允许我的 WinForms 项目中的 app.config 文件进行 XDT 转换,类似于我的 Web 项目的 web.config 文件的转换方式。好吧,如果您从 SO 复制并复制到 .csproj 或 .vbproj 源文件中,那么它就可以在 OOTB 中工作。但是,一旦您将所有这些放到没有 Visual Studio 的构建服务器上,关键部分就会由于依赖于以下内容而失败:

 $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets

现在这已经足够简单了,可以纠正..我刚刚将我的 C:\ 复制到 CI 服务器Program Files (x86)\MSBuild\Microsoft 目录。 但是,我应该吗?因为我有点放弃了 Visual Studio 通常支持的保留..有人可能会说 @TomasLycken 接受的答案在这个问题上仍然是正确的点,也。

3 - 将所有 .NET 框架和多目标包安装到位

上面的第 1 点和第 2 点实际上是我在尝试获得第一个目标时所克服的最后事情构建要运行的作业。我的第一个构建工作是针对我在过去 8 年中创建和维护的解决方案堆栈。因此它已经经历了一些框架的考验,并且具有一些重要的纹理。我知道这并不容易。事实上,我希望通过创建一个可以构建 this .sln 的 CI 服务器,它实际上已经准备好构建我们向其提供的大多数其他解决方案。

当我第一次收到干净的“Windows 2012 R2”服务器时,它只是缺少了很多东西..我想知道我是否先安装了 Visual Studio,它是否会立即纠正其中一些东西?

以下是我必须做的事情的概要 - 但它并没有显示出解决所有问题和错误开始所涉及的痛苦和磨难。不过,也许它会对其他人有帮助。

> First, uninstalled 4.6.1 framework
-- (find Update for Microsoft Windows (KB3102467) and click Uninstall.)
-- also uninstalled anything from MS labeled with C++ redistributable (a later step will restore these)

> Then, install Windows 7 SDK (installs critical "reference assemblies" and a proper baseline 4.0 framework)
-- Then, install Multi-Targeting Pack for Framework 4.0.1 (netfx_401mtpack.exe)
-- Then, install Multi-Targeting Pack for Framework 4.0.3 (netfx_403mtpack.exe)

> Then, reinstalled 4.6.1 framework for 2012 R2 (KB3102467) 

> Then, installed Microsoft .NET Framework 4.6.1 Developer Pack (DP461-DevPack-KB3105179-ENU.exe)

> Then, installed "Visual Studio 2015 Build Tools" (BuildTools_Full.exe)

> Downloaded a copy of nuget.exe and put it in the C:\Windows directory

4 - 摆脱“缺少规则集”警告 MSB3884

来自 @kevinbosman 在 此 GitHub 问题主题

如果您不想编辑 Microsoft.CodeAnalysis.Targets 文件,请注意,仅复制文件夹 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools 是不够的\Static Analysis Tools\Rule Sets\ 到构建服务器。

您还需要创建注册表项 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\Setup\EDev 并添加字符串值 StanDir = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\

5 - 让 MSTest 正确运行

  • 需要将 dll 复制到构建计算机中,有些必须使用 GAC 注册更多信息具体如下:
    • Microsoft.VisualStudio.QualityTools.Resource.dll
    • Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
  • 需要从您的开发计算机注册表中将一些警告复制到构建服务器中
  • 如果您希望它们消失,则 ,根据 此 Microsoft Visual Studio 帮助论坛需要安装 VS 2010 和功能包 2

You might need to install Visual Studio anyway, out of practicality

I was going to try and refute the accepted answer, posted by @TomasLycken, in the comments, but found I needed more space to talk. Even though I technically agree with what @TomasLycken has asserted, here, I'll list some of the dependencies that I found difficult to install on my CI server - and leave it to you to decide how right the accepted answer is...

1 - 'mshtml' primary interop assembly

You can see the problem I was getting in my build output at this S.O. question I created and answered. Mind you, I spent several hours figuring out how get the desired PIA registered - and it was a result of running some .exe's on the server that came from my V.Studio installation - hmmmmmm

CONTEXT: I had a win forms project that used the Web Browser control.. and in the 'WebDocumentCompleted' event, I was casting the DomDocument to hshtml.IHTMLDocument2 .. and that's why I had a reference to Microsoft.mshtml in my project.

RESULT: Now @TomasLycken suggests I deal with this by fixing my code. At first, I wanted to bawk at this suggestion. My code is deployed and working! But, when I do a web search, I see that Microsoft doesn't really recommend using their mshtml PIA outside of the Visual Studio environment they developed it for.

The offending 10 lines of code was effectively doing a little screen-scraping of data on behalf of our users who do research on technical topics in several well-known web portals. But, when I tested this code, written in 2009, it appears that the DOM it once manipulated has now changed in 2016. I know shocking. Probably not my smartest bit of code. Probably time to retire this function - in other words, fix the code and recommit it.

@TomasLyken I think is right on this one.

2 - Win Forms Project post-build script

CONTEXT: So I had come across this cool post-build technique on S.O. that allows my app.config file in my WinForms project to undergo an XDT transform similar to the way my web projects' web.config files are transformed. Well, it just works OOTB, so-to-speak, if you copy from S.O. and into the .csproj or .vbproj source file. But, once you put all this onto a build server with no Visual Studio, the critical piece fails due to a dependency on:

 $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets

Now this is straightfoward enough to rectify.. I just copied over to the CI server my C:\Program Files (x86)\MSBuild\Microsoft directory. But, should I? Since I've kinda went off the reservation of what Visual Studio normally would support.. one could argue that @TomasLycken's accepted answer is still right on this point, too.

3 - Just getting all the .NET Frameworks and Multi-Targeting Packs in place

Points 1 and 2 above, were actually the last things I conquered in my attempt to get my first build job to run. And my first build job is for a solution stack that I've created and maintained over the past 8 years.. so it has weathered a few frameworks and would have some non-trivial texture to it. I knew it wouldn't be easy. In fact, I hoped by making a CI server that could build this .sln, that it would in fact be ready to build most any other solution we threw at it.

When I first received my clean "Windows 2012 R2" server, it simply had a lot of things missing.. and I'm wondering if I had installed Visual Studio first, if it would have rectified some of these things straight off?

Below is my synopsis of what I had to do - but it doesn't show the pain and suffering involved figuring it all out and the false starts. Maybe it'll help someone else, though.

> First, uninstalled 4.6.1 framework
-- (find Update for Microsoft Windows (KB3102467) and click Uninstall.)
-- also uninstalled anything from MS labeled with C++ redistributable (a later step will restore these)

> Then, install Windows 7 SDK (installs critical "reference assemblies" and a proper baseline 4.0 framework)
-- Then, install Multi-Targeting Pack for Framework 4.0.1 (netfx_401mtpack.exe)
-- Then, install Multi-Targeting Pack for Framework 4.0.3 (netfx_403mtpack.exe)

> Then, reinstalled 4.6.1 framework for 2012 R2 (KB3102467) 

> Then, installed Microsoft .NET Framework 4.6.1 Developer Pack (DP461-DevPack-KB3105179-ENU.exe)

> Then, installed "Visual Studio 2015 Build Tools" (BuildTools_Full.exe)

> Downloaded a copy of nuget.exe and put it in the C:\Windows directory

4 - Getting rid of 'missing ruleset' warning MSB3884

From @kevinbosman's post on this GitHub issues thread

If you don't want to edit your Microsoft.CodeAnalysis.Targets file, please note that it is not enough to merely copy the folder C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\ to the build server.

You also need to create the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\Setup\EDev and add the string value StanDir = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\

5 - Getting MSTest to run correctly

  • Need dlls copied into your build machine, some must register w/GAC more info here specifically:
    • Microsoft.VisualStudio.QualityTools.Resource.dll
    • Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
  • Need a hive out of your dev machine's registry copied into build server
  • some warnings, if you want them to go away, according to this Microsoft visual studio help forum require a VS 2010 and feature pack 2 installation.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文