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

11,240

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.

Share:
11,240
Kunal Shah
Author by

Kunal Shah

Updated on June 03, 2022

Comments

  • Kunal Shah
    Kunal Shah almost 2 years

    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.

  • Kunal Shah
    Kunal Shah almost 8 years
    Hi Scott, Thanks for quick reply! Issue was on the Agent which the Team city was using as reference for doing build. That agent machine was not having some dependencies installed. Like, F# 4.0
  • WEFX
    WEFX almost 6 years
    How would someone confirm or change this?