简体   繁体   English

构建服务器上的ASP.NET v5

[英]ASP.NET v5 on a Build Server

I'm trying to build a VS2015 ASP.NET v5 web app on our build server (basically, outside of Visual Studio). 我正在尝试在我们的构建服务器上构建一个VS2015 ASP.NET v5 Web应用程序(基本上,在Visual Studio之外)。 Our existing scripts simply invoke msbuild with the csproj file, but with this project I get: 我们现有的脚本只是用csproj文件调用msbuild,但是我得到了这个项目:

Project File is empty 项目文件为空

What is the "story" for "building" these new webapps outside Visual Studio? 在Visual Studio之外“构建”这些新的Web应用程序的“故事”是什么? I believe they can still target .NET 4.5 (I hope so, as we're not upgrading web servers any time soon) so assumed it were possible. 我相信他们仍然可以针对.NET 4.5(我希望如此,因为我们不会很快升级Web服务器)所以假设它是可能的。

Well there is no .csproj in a dnx project everything that is needed for dnu to build a project is contained in the project.json . 好吧,在dnx项目中没有.csproj dnu构建项目所需的一切都包含在project.json There is a xproj file but you can ignore that. 有一个xproj文件,但你可以忽略它。 Microsoft has finally decided to see the light and uses xproj just for VS specific "stuff" and IDE agnostic project details are put in the project.json. 微软最终决定看到光明,并使用xproj仅用于VS特定的“东西”,IDE不可知的项目细节放在project.json中。

So to build a dnx project all you need is the right version of dnx and the project source code. 因此,要构建一个dnx项目,您只需要正确版本的dnx和项目源代码。 Now AFAIK there are no out of the box solutions but everything is done with command line commands so script something up should be easy. 现在AFAIK没有开箱即用的解决方案,但一切都是通过命令行命令完成的,所以脚本应该很容易。 It all depends on how robust of a solution you want to build. 这一切都取决于您想要构建的解决方案的稳健性。

To build a dnx project from the command line (assuming you have the proper dnx installed and set to active) it is just two commands. 要从命令行构建一个dnx项目(假设你安装了正确的dnx并设置为active),它只是两个命令。 dnu restore runs a dependency check and dnu (a part of dnx) has a built in nuget client so it will reach out and grab dependencies if needed. dnu restore运行依赖项检查,dnu(dnx的一部分)有一个内置的nuget客户端,因此它会在需要时伸出并获取依赖项。 dnu build runs that actual compilation. dnu build运行实际编译。

So cd to the project root (which contains project.json) and run dnu restore then dnu build . 所以cd到项目根目录(包含project.json)并运行dnu restore然后运行dnu build

It gets more complex if you need to dynamically support different dnx versions. 如果您需要动态支持不同的dnx版本,它会变得更复杂。 Keep in mind dnx versions are identified by runtime (coreclr or clr), architecture (x86, x64, etc), and a version number. 请记住,dnx版本由运行时(coreclr或clr),体系结构(x86,x64等)和版本号标识。 So if you are only targetting say x64 builds on clr (full .net runtime) that eliminates two variables but what happens if a project requires a newer version of the runtime than what is installed on the build server? 因此,如果你只是在clr(完整的.net运行时)上说x64构建,它消除了两个变量,但是如果项目需要比构建服务器上安装的更新版本的运行时会发生什么? As an example say you installed (manually using dnvm) dnx-clr-win-x64.1.0.0-beta4 on the build server but at some point in the future a developer requires dnx-clr-win-x64.1.0.0-beta6-1200 to resolve a bug. 举个例子说你在构建服务器上安装了(手动使用dnvm)dnx-clr-win-x64.1.0.0-beta4但是在将来某个时候开发人员需要dnx-clr-win-x64.1.0.0- beta6-1200来解决一个bug。

The simplistic solution would be just to install new runtime versions as needed and build all projects against the newest one needed. 简单的解决方案只是根据需要安装新的运行时版本,并根据所需的最新版本构建所有项目。 This isn't as bad as it might first sound. 这并不像它最初听起来那么糟糕。 Once dnx gets out of beta changes to the runtime should be infrequent. 一旦dnx退出测试版,运行时的更改应该不常见。 Remember the runtime is the very low level code and unmanaged dlls. 请记住,运行时是非常低级别的代码和非托管dll。 It is the bootstrapping stub that the BCL sits on top of. 它是BCL位于其上的引导存根。 Hopefully there should not be that many changes to the dnx for a given OS, architecture and runtime. 希望对于给定的操作系统,体系结构和运行时,不应该对dnx进行那么多的更改。

For a more robust solution you could use scripting to find the runtime version required for a project. 对于更强大的解决方案,您可以使用脚本来查找项目所需的运行时版本。 It is found in a solution level global.json . 它位于解决方案级别global.json The script could then use dnvm list to determine if it has that runtime installed. 然后,该脚本可以使用dnvm list来确定它是否已安装该运行时。 If it doesn't then use dnvm install or dnvm upgrade to install the required version. 如果没有,则使用dnvm installdnvm upgrade来安装所需的版本。 Before starting the build it would use the command dnvm use to make the correct runtime active and then proceed with dnu restore and dnu build . 在开始构建之前,它将使用命令dnvm use来使正确的运行时处于活动状态,然后继续进行dnu restorednu build

Honestly I expect some pretty robust solutions to come along. 老实说,我希望有一些非常强大的解决方案。 Task runners (gulp, grunt, etc) are first class citizens in .NET 5. Most likely your workflow will involve bower for client side dependency resolution, npm, grunt/gulp and some task packages for things like minifying js files. 任务运行者(gulp,grunt等)是.NET 5中的一等公民。很可能你的工作流程涉及bower用于客户端依赖项解析,npm,grunt / gulp和一些任务包,用于缩小js文件。 The build server is going to need all that as well so having a build task as a grunt or gulp package seems a pretty good fit. 构建服务器也需要所有这些,因此将构建任务作为grunt或gulp包看起来非常合适。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM