用于构建xproj的Microsoft.DotNet.Props目录不存在

时间:2017-11-11 16:08:54

标签: msbuild .net-core azure-service-fabric

我们正在尝试构建一个xproj项目以及一个无法找到Microsoft.DotNet.Props文件的错误,因为它看起来好像在查看错误的目录。

查看目录C:\Program Files\dotnet\sdk\1.1.4\不存在的xml MSBuildExtensionsPath32引用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.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市场&#34; MicrosoftVisualStudio / VisualStudio / VS-2015-Comm-VSU3-AzureSDK-29-WS2012R2 / 2017.10.12&#34; - 附带更新3的Visual Studio 2015社区版。 Azure SDK 2.9。从旧版本v0.12升级到v8.x.升级的.NET核心从不确定安装到1.1.4。
  • xproj本身没有代码 - 除了Startup.cs中的少量代码以提供静态文件(帖子底部的代码)。
  • 该应用程序也用于Service Fabric项目。这个错误不是来自构建.sln,而是在打包.sfproj时(它可能没有设置为在sln中构建,但打包需要构建它)。

Jenkins build steps

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>

1 个答案:

答案 0 :(得分:1)

您正在尝试将预览工具(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工具。