简体   繁体   中英

error MSB4102: The value “” of the “Project” attribute in element <Import> is invalid. Parameter “path” cannot have zero length. F#

I am getting following error while building project in Team city.

Same project is getting build on Local machine. Local machine has VS 2015 and F# 4.0.

My Project Configuration is as below.

<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />


    <Choose>
        <When Condition="'$(VisualStudioVersion)' == '11.0'">
          <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets')">
            <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
          </PropertyGroup>
        </When>
        <Otherwise>
          <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
            <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
          </PropertyGroup>
        </Otherwise>
      </Choose>
      <Import Project="$(FSharpTargetsPath)" />

This is Console application.

I had a similar problem a while back, because I was running the local machine with Administrator privileges, but the Visual Studio installer had set environment variables at the user level and not the system level which Administrator uses. So when compiling as Administrator, the FSharpTargetsPath was not being correctly built from environment variables like VisualStudioVersion .

Have a look on your local machine to see what environment variables values are set for VisualStudioVersion at the level you are successfully using (System or User), as well as other variables and then check that these are set at the corresponding level on the Team City machine.

Perhaps you are running as user on your local machine and System on the Team City machine.

See details here: https://stackoverflow.com/a/21420306/152739

I hope this makes sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM