Microsoft.DotNet.Props 构建 xproj 的目录不存在
Microsoft.DotNet.Props directory does not exist for building xproj
我们正在尝试构建一个 xproj 项目,但出现无法找到 Microsoft.DotNet.Props 文件的错误,因为它似乎在寻找错误的目录。
查看 xml MSBuildExtensionsPath32 引用 C:\Program Files\dotnet\sdk.1.4\
,其中目录 Microsoft\VisualStudio\..
不存在...但正常的 MSBuild 目录 C:\Program Files (x86)\MSBuild
确实有该目录对于 Microsoft.DotNet.Props 文件 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props
这是XML
的一部分
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
我在构建时看到的错误是:
error MSB4019: The imported project "C:\Program Files\dotnet\sdk.1.4\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
如果有人知道发生了什么,帮助会很大
编辑:
- 构建是从 Windows Server 2012 R2 上的 Jenkins 项目调用的。
- VM 映像来自 Azure 市场 "MicrosoftVisualStudio / VisualStudio / VS-2015-Comm-VSU3-AzureSDK-29-WS2012R2 / 2017.10.12" - Visual Studio 2015 社区版更新 3。
Azure SDK 2.9。将节点从旧的 v0.12 升级到 v8.x。将 .NET 核心从不确定安装了什么升级到 1.1.4。
- xproj 本身没有代码 - 除了 Startup.cs 中的少量代码以提供静态文件(post 底部的代码)。
- 该应用程序还在 Service Fabric 项目中使用。错误不是来自构建 .sln,而是来自打包 .sfproj 时(它可能未设置为在 sln 中构建,但打包需要构建它)。
Startup.cs:
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Website
{
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404
&& !Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = "/index.html";
await next();
}
});
app.UseStaticFiles();
}
}
}
编辑:这是整个 xproj xml
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<ProjectGuid>17107df8-0cfa-6946-917a-a9b8765cf9ea</ProjectGuid>
<RootNamespace>Website</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
</PropertyGroup>
<ItemGroup>
<DnxInvisibleContent Include="bower.json" />
<DnxInvisibleContent Include=".bowerrc" />
</ItemGroup>
<ItemGroup>
<DnxInvisibleFolder Include="wwwroot\Angular\dist\" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b69-4b1e-b82e-3ada8210c987}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
您正在尝试将预览工具 (xproj) 与 1.1.4 版的 .NET Core Sdk 结合使用。 VS 2015 中可用的预览工具不适用于 .NET Core 的 1.0+ 稳定工具。
确保在您的开发机器和 Jenkins 服务器上都安装了 .NET Core SDK 的 preview2 版本 - 例如1.0.0-preview2-003156
- 并且 global.json
文件存在于您的解决方案目录中以告知 VS 使用此预览版 SDK:
{
"sdk": {
"version": "1.0.0-preview2-003156"
}
}
作为长期解决方案,我建议通过迁移到 VS 2017 来迁移到稳定且受支持的 .NET Core 工具。
我们正在尝试构建一个 xproj 项目,但出现无法找到 Microsoft.DotNet.Props 文件的错误,因为它似乎在寻找错误的目录。
查看 xml MSBuildExtensionsPath32 引用 C:\Program Files\dotnet\sdk.1.4\
,其中目录 Microsoft\VisualStudio\..
不存在...但正常的 MSBuild 目录 C:\Program Files (x86)\MSBuild
确实有该目录对于 Microsoft.DotNet.Props 文件 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props
这是XML
的一部分<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
我在构建时看到的错误是:
error MSB4019: The imported project "C:\Program Files\dotnet\sdk.1.4\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
如果有人知道发生了什么,帮助会很大
编辑:
- 构建是从 Windows Server 2012 R2 上的 Jenkins 项目调用的。
- VM 映像来自 Azure 市场 "MicrosoftVisualStudio / VisualStudio / VS-2015-Comm-VSU3-AzureSDK-29-WS2012R2 / 2017.10.12" - Visual Studio 2015 社区版更新 3。 Azure SDK 2.9。将节点从旧的 v0.12 升级到 v8.x。将 .NET 核心从不确定安装了什么升级到 1.1.4。
- xproj 本身没有代码 - 除了 Startup.cs 中的少量代码以提供静态文件(post 底部的代码)。
- 该应用程序还在 Service Fabric 项目中使用。错误不是来自构建 .sln,而是来自打包 .sfproj 时(它可能未设置为在 sln 中构建,但打包需要构建它)。
Startup.cs:
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Website
{
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404
&& !Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = "/index.html";
await next();
}
});
app.UseStaticFiles();
}
}
}
编辑:这是整个 xproj xml
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<ProjectGuid>17107df8-0cfa-6946-917a-a9b8765cf9ea</ProjectGuid>
<RootNamespace>Website</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
</PropertyGroup>
<ItemGroup>
<DnxInvisibleContent Include="bower.json" />
<DnxInvisibleContent Include=".bowerrc" />
</ItemGroup>
<ItemGroup>
<DnxInvisibleFolder Include="wwwroot\Angular\dist\" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b69-4b1e-b82e-3ada8210c987}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
您正在尝试将预览工具 (xproj) 与 1.1.4 版的 .NET Core Sdk 结合使用。 VS 2015 中可用的预览工具不适用于 .NET Core 的 1.0+ 稳定工具。
确保在您的开发机器和 Jenkins 服务器上都安装了 .NET Core SDK 的 preview2 版本 - 例如1.0.0-preview2-003156
- 并且 global.json
文件存在于您的解决方案目录中以告知 VS 使用此预览版 SDK:
{
"sdk": {
"version": "1.0.0-preview2-003156"
}
}
作为长期解决方案,我建议通过迁移到 VS 2017 来迁移到稳定且受支持的 .NET Core 工具。