在没有 Visual Studio 的情况下构建 Class 库(包)NuGet 包项目

Build Class Library (Package) NuGet Package Projects Without Visual Studio

在没有安装 Visual Studio 的情况下使用 MSBUILD 构建新的 'Class Library (Package)' (.xproj) 项目(也被 ASP.NET 5 使用)我需要做什么?我目前收到以下错误:

C:\Source\MyProject.xproj(7,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\DNX\Microsoft.DNX.Props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

我只针对 .NET 4.5.2,我已经安装了 Microsoft Build Tools 2015 并且想在我的构建服务器上执行此操作。

更新

看来我可以 dnu publish 来实现这一点,但这仅适用于单个 .xproj 项目。如果我想在我的构建环境的解决方案中发布多个项目怎么办?单独添加项目不是很方便

MSBUILD MySolution.sln 会对标准 class 库执行此操作。有没有办法让 MSBUILD MySolution.sln 为这种情况工作?

尝试使用 dnu 构建。 (VS2015 也使用这个)所有的 aspnet repro 都可以在没有 VS2015 的情况下使用 build.cmd 构建。

有关示例,请参见 asp livedatatables

您可以使用 dnu pack 创建 nuget 包。输入 dnu pack --help 获取更多信息

为什么需要 msbuild?

您只需要 dnvm 就可以获得 dnx。之后你可以 运行 dnu pack 并生成包。

检查 dnvm list 以确保您打算构建的版本与您的项目目标相匹配。如果没有,请使用 dnvm use 进行设置或 dnvm install 进行安装。

然后 cd /your/solution/direcotry 和;

dnu restore
dnu build *