title: References to NuGet packages cannot be resolved in F# project being built in VSTS
body: <p>With Visual Studio 2017 Community I have created a solution with a F# library project (regular, not PCL) targeting the .NET 4.5.2 framework and the F# 4.1 (FSharp.Core, 4.4.1.0) runtime. Visual Studio added for me the NuGet reference to System.ValueType (4.3.0) by default.</p>
  
  <p>The only code in this project is the following which is using <code>System.ValueType</code>:</p>
  
  <pre><code>type TupleCreator() =
    member this.Create x = 
      System.ValueTuple.Create(x)
  </code></pre>
  
  <p>Building the project locally works fine, unfortunately this is not the case with VSTS. I have a build definition (with default agent queue set to <code>Hosted VS2017</code>) with a NuGet restore step and a build solution step (with Visual Studio Version set to Latest).</p>
  
  <p>When the build runs it succeeds in restoring the nuget packages:</p>
  
  <pre><code>##[section]Starting: NuGet restore **\*.sln
  =================================================================
  Task         : NuGet Installer
  Description  : Installs or restores missing NuGet packages
  Version      : 0.2.31
  Author       : Microsoft Corporation
  =================================================================
  [command]C:\Windows\system32\chcp.com 65001
  Active code page: 65001
  Detected NuGet version 3.3.0.212 / 3.3.0
  SYSTEMVSSCONNECTION exists true
  To connect to NuGet feeds hosted in your Team Services account/TFS project collection on this build agent, edit your build definition to choose a higher version of nuget or specify a path to a NuGet.config containing the package sources you wish to use.
  [command]d:\a\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe restore -NonInteractive d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.sln
  MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework\v4.0.30319'.
  Feeds used:
    C:\Users\buildguest\AppData\Local\NuGet\Cache
    https://api.nuget.org/v3/index.json
  Restoring NuGet package System.ValueTuple.4.3.0.
  Adding package 'System.ValueTuple.4.3.0' to folder 'd:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\packages'
  Added package 'System.ValueTuple.4.3.0' to folder 'd:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\packages'
  ##[section]Finishing: NuGet restore **\*.sln
  </code></pre>
  
  <p>The build step then yields the following log:</p>
  
  <pre><code>##[section]Starting: Build solution $/tfs1/Apps/Sandbox/FSharpWithNugetDemo/FSharpWithNugetDemo.sln
  ==============================================================================
  Task         : Visual Studio Build
  Description  : Build with MSBuild and set the Visual Studio version property
  Version      : 1.117.0
  Author       : Microsoft Corporation
  Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613727)
  ==============================================================================
  ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.117.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,15.1) -latest -format json
  ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.117.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=d08ecee6-b628-4743-9e80-d31a64026956|SolutionDir=d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.117.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:TreatWarningsAsErrors=False /p:platform="any cpu" /p:configuration="debug" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_1e91f890-819e-4329-aa62-069b62ae16d0_build_4_116"
  Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  Build started 5/24/2017 6:32:52 PM.
  Project "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.sln" on node 1 (default targets).
  ValidateSolutionConfiguration:
    Building solution configuration "debug|any cpu".
  Project "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.sln" (1) is building "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.fsproj" (2) on node 1 (default targets).
  PrepareForBuild:
    Creating directory "bin\Debug\".
    Creating directory "obj\Debug\".
  ResolveAssemblyReferences:
    Primary reference "System.ValueTuple".
  ##[warning]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.ValueTuple". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.ValueTuple". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.fsproj]
            For SearchPath "{HintPathFromItem}".
            Considered "..\..\Sandbox (local)\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll", but it didn't exist.
            For SearchPath "{TargetFrameworkDirectory}".
            Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.ValueTuple.winmd", but it didn't exist.
            Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.ValueTuple.dll", but it didn't exist.
            Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.ValueTuple.exe", but it didn't exist.
            .
            .
            .
            Considered "bin\Debug\System.ValueTuple.exe", but it didn't exist.
  CoreCompile:
    C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\fsc.exe -o:obj\Debug\FSharpWithNugetDemo.dll
    -g
    --debug:full
    --noframework
    --define:DEBUG
    --define:TRACE
    --doc:bin\Debug\FSharpWithNugetDemo.XML
    --optimize-
    --tailcalls-
    -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.4.1.0\FSharp.Core.dll
    -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\mscorlib.dll
    -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Core.dll
    -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.dll
    -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Numerics.dll
    --target:library
    --warn:3
    --warnaserror:76
    --fullpaths
    --flaterrors
    --subsystemversion:6.00
    --highentropyva+
    d:\a\_temp\.NETFramework,Version=v4.5.2.AssemblyAttributes.fs
    AssemblyInfo.fs
    Library1.fs
  ##[error]Apps\Sandbox\FSharpWithNugetDemo\Library1.fs(5,12): Error FS0039: The value, constructor, namespace or type 'ValueTuple' is not defined. Maybe you want one of the following:   ValueType
  d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\Library1.fs(5,12): error FS0039: The value, constructor, namespace or type 'ValueTuple' is not defined. Maybe you want one of the following:   ValueType [d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.fsproj]
  Done Building Project "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.fsproj" (default targets) -- FAILED.
  Done Building Project "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.sln" (default targets) -- FAILED.
  
  Build FAILED.
  
  "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.sln" (default target) (1) -&gt;
  "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.fsproj" (default target) (2) -&gt;
  (ResolveAssemblyReferences target) -&gt; 
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.ValueTuple". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.fsproj]
  
  "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.sln" (default target) (1) -&gt;
  "d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.fsproj" (default target) (2) -&gt;
  (CoreCompile target) -&gt; 
    d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\Library1.fs(5,12): error FS0039: The value, constructor, namespace or type 'ValueTuple' is not defined. Maybe you want one of the following:   ValueType [d:\a\3\s\Apps\Sandbox\FSharpWithNugetDemo\FSharpWithNugetDemo.fsproj]
  
      1 Warning(s)
      1 Error(s)
  
  Time Elapsed 00:00:06.14
  ##[error]Process 'msbuild.exe' exited with code '1'.
  </code></pre>
  
  <p>This is not an issue with <code>System.ValueType</code> because the build process is unable to build with references to any nuget packages. This is also not an issue with my VSTS because my C# projects with NuGet references get built fine.</p>
  
  <p>What is wrong with my F# project? Are there additional steps to be taken in order to enable NuGet in F# projects on VSTS?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I just compared the output of the <code>CoreCompile</code> section with what is printed in Visual Studio. In Visual Studio it says:</p>
  
  <pre><code>C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\fsc.exe -o:obj\Debug\FSharpWithNugetDemo.dll
  -g
  --debug:full
  --noframework
  --define:DEBUG
  --define:TRACE
  --doc:bin\Debug\FSharpWithNugetDemo.XML
  --optimize-
  --tailcalls-
  -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.4.1.0\FSharp.Core.dll
  -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\mscorlib.dll
  -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Core.dll
  -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.dll
  -r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Numerics.dll
  -r:D:\Projects\Sandbox\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll
  .
  .
  .
  --target:library
  --warn:3
  --warnaserror:76
  --vserrors
  --utf8output
  --fullpaths
  --flaterrors
  --subsystemversion:6.00
  --highentropyva+
  C:\Users\David\AppData\Local\Temp\.NETFramework,Version=v4.5.2.AssemblyAttributes.fs
  AssemblyInfo.fs
  Library1.fs
  FSharpWithNugetDemo -&gt; D:\Projekte\VisualStudio.com\sphereutfs\Dev\Apps\Sandbox\FSharpWithNugetDemo\bin\Debug\FSharpWithNugetDemo.dll
  </code></pre>
  
  <p>The difference is that there is a <code>-r:</code> line with a path to the <code>System.ValueTuple.dll</code> obtained from NuGet which is missing in the log of the VSTS build. How can I tell the VSTS build to include this reference when compiling?</p>