使用 Cake build 构建引用网络标准库的 Net Framework Web 应用程序 [英] Build Net Framework web application referencing net-standard library with Cake build

查看:21
本文介绍了使用 Cake build 构建引用网络标准库的 Net Framework Web 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个项目:NET Standard 类库和常规 NET Framework Web 应用程序.Web 应用程序引用类库.

I have two projects: NET Standard class library and regular NET Framework web application. Web application references class library.

我使用 Visual Studio 2017 预览版.

当我尝试使用 MSBuild 命令使用 Cake 构建解决方案时,我收到不支持的项目消息:

When I try to build the solution with Cake using MSBuild command I get the unsupported project message:

error MSB4041:项目的默认 XML 命名空间必须是 MSBuild XML 命名空间.如果项目是在MSBuild 2003 格式,请将 xmlns="http://schemas.microsoft.com/developer/msbuild/2003" 添加到<Project>元素.如果项目已经以旧的 1.0 或 1.2 格式创作,请将其转换为 MS构建 2003 格式.

如果我尝试使用 DotNetCoreBuild 我得到:

If I try to use DotNetCoreBuild I get:

error MSB4019:导入的项目C:Program Filesdotnetsdk2.0.2-vspre​​-006949MicrosoftVisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets" 未找到.请确认 <Import> 声明中的路径正确,并且该文件存在于磁盘上.

但该解决方案是由 Visual Studio 成功构建的.

But the solution is built successfully by Visual Studio.

推荐答案

最新 MSBuild 版本具有构建 NET Standard 库的目标.问题出在 Visual Studio Preview 安装路径:Cake 找不到最新的 MSBuild.

Latest MSBuild version has the targets to build NET Standard libraries. The problem is in Visual Studio Preview installation path: Cake can't find the latest MSBuild.

如果您尝试在 VS2017,它也会失败rel="nofollow noreferrer">MSBuildToolVersion.

It will also fail if you will try to specify VS2017 in MSBuildToolVersion.

您必须手动指定 MSBuild 可执行文件才能使其与 VS Preview 一起使用.

You have to specify the MSBuild executable manually to make it work with VS Preview.

string msBuildPath = @"c:Program Files (x86)Microsoft Visual StudioPreviewProfessionalMSBuild15.0BinMSBuild.exe";

MSBuild("../NetStdExample.sln", new MSBuildSettings {
    Verbosity = Verbosity.Minimal,
    ToolPath = msBuildPath
});

@Gary Ewan Park 更新:有一个 工具用于确定最新的 VS 安装.

Update by @Gary Ewan Park: there is a tool for determining latest VS install.

这篇关于使用 Cake build 构建引用网络标准库的 Net Framework Web 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆