gpt4 book ai didi

visual-studio-2015 - 是否可以使用代码中的 MSBuild 构建 asp.net 核心项目?

转载 作者:行者123 更新时间:2023-12-01 07:12:36 26 4
gpt4 key购买 nike

我想使用另一个 C# 项目构建 asp.net 核心项目。这是示例代码。 (我正在使用 Visual Studio 2015)

var projectCollection = new Microsoft.Build.Evaluation.ProjectCollection(Microsoft.Build.Evaluation.ToolsetDefinitionLocations.Registry);
projectCollection.DefaultToolsVersion = "14.0";
projectCollection.RegisterLogger(new Microsoft.Build.Logging.ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Detailed));
var project = projectCollection.LoadProject(@"H:\Development\WebApplication22\src\WebApplication22\WebApplication22.xproj");
bool b = project.Build();

它给了我很多错误。以下是其中之一。

The "GetTransitiveNonDotNetProjectDependencies" task could not be loaded from the assembly C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Tasks.dll. Method 'get_BuildEngine' in type 'Microsoft.DotNet.Tasks.KProcess' from assembly 'Microsoft.DotNet.Tasks, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. Done building target "_GetDependencyFragmentFiles" in project "WebApplication22. xproj" -- FAILED.

注意:如果我使用 Visual Studio 命令提示符并使用 MSbuild,那么它工作正常。

最佳答案

暂时没有。当您从 Visual Studio 命令提示符运行 msbuild 以构建 asp.net 核心项目时,它将调用 dotnet.exe 进行构建。

MS 目前正在努力从 .xproj/project.json 迁移到 .csproj/MSBuild,并且最有可能在 Visual Studio 15 RTM 中可用。您可以引用此链接了解更多信息:Changes to Project.json .

The first wave of this change will happen in the Visual Studio “15” RTM: when opening any .NET Core project in Visual Studio, it will automatically convert from .xproj to .csproj, moving the assets from the project.json file into configuration files and the .csproj file. We will also provide a tool for converting applications using the .NET command line tools as well.

关于visual-studio-2015 - 是否可以使用代码中的 MSBuild 构建 asp.net 核心项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38934699/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com