title: MSBuild giving "invalid version file" on F#
body: <p>I'm recently unable to build F# with MSBuild.  It is giving me an error "invalid version file".  The generated compiler options below show <code>--versionfile:version.htm</code> being added, and I'm not sure why.</p>
  
  <p>I did find that if I go to <code>C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.targets</code>, and remove the line <code>VersionFile="$(VersionFile)"</code> it starts working again.  However I don't know where that file came from or why that line is there, and I don't want to be working with a non-standard dev box.  Can anyone shed light on what's happening here?</p>
  
  <p>Here's a dump of the whole output.</p>
  
  <pre><code>$ "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj"
  Microsoft (R) Build Engine version 14.0.25420.1
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  Build started 5/4/2017 6:10:21 PM.
  Project "C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj" on node 1 (default targets).
  CoreCompile:
    C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\fsc.exe -o:obj\Debug\Library1.dll -g --debug:full --noframework --define:DEBUG --define
    :TRACE --doc:bin\Debug\Library1.XML --optimize- --tailcalls- --versionfile:version.htm -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FS
    harp\.NETFramework\v4.0\4.4.0.0\FSharp.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\mscorlib.dl
    l" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Core.dll" -r:"C:\Program Files (x86)\Reference Ass
    emblies\Microsoft\Framework\.NETFramework\v4.6\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\S
    ystem.Numerics.dll" --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ "C:\Users\dafohl\A
    ppData\Local\Temp\.NETFramework,Version=v4.6.AssemblyAttributes.fs" AssemblyInfo.fs Library1.fs
  
  FSC : warning FS0075: The command-line option 'versionfile' is for test purposes only [C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1 \Library1\Library1.fsproj]
  
  FSC : warning FS2015: The 'AssemblyVersionAttribute' has been ignored because a version was given using a command line option [C:\Users\dafohl\Docume nts\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj]
  
  FSC : error FS0205: Invalid version file 'C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\version.htm' [C:\Users\dafohl\Docum ents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj]
  Done Building Project "C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj" (default targets) -- FAILED.
  
  
  Build FAILED.
  
  "C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj" (default target) (1) -&gt;
  (CoreCompile target) -&gt;
    FSC : warning FS0075: The command-line option 'versionfile' is for test purposes only [C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Librar y1\Library1\Library1.fsproj]
    FSC : warning FS2015: The 'AssemblyVersionAttribute' has been ignored because a version was given using a command line option [C:\Users\dafohl\Docu ments\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj]
  
  
  "C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj" (default target) (1) -&gt;
  (CoreCompile target) -&gt;
    FSC : error FS0205: Invalid version file 'C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\version.htm' [C:\Users\dafohl\Doc uments\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj]
  
      2 Warning(s)
      1 Error(s)
  
  Time Elapsed 00:00:00.68
  </code></pre>
  
  <p>Here are the original contents of <code>Microsoft.FSharp.targets</code>:
      
  
  <pre><code>WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
            created a backup copy.  Incorrect changes to this file will make it
            impossible to load or build your projects from the command-line or the IDE.
  
  This file defines the steps in the standard build process specific for F# .NET projects.
  For example, it contains the step that actually calls the F# compiler.  The remainder
  of the build process is defined in Microsoft.Common.targets, which is imported by 
  this file.
  
  Copyright (C) Microsoft Corporation. All rights reserved.
  ***********************************************************************************************
  --&gt;
  
  &lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  
      &lt;UsingTask TaskName="Fsc" AssemblyFile="FSharp.Build.dll"/&gt;
      &lt;UsingTask TaskName="CreateFSharpManifestResourceName" AssemblyFile="FSharp.Build.dll"/&gt;
  
      &lt;PropertyGroup&gt;
          &lt;ImportByWildcardBeforeMicrosoftFSharpTargets Condition="'$(ImportByWildcardBeforeMicrosoftFSharpTargets)' == ''"&gt;true&lt;/ImportByWildcardBeforeMicrosoftFSharpTargets&gt;
          &lt;ImportByWildcardAfterMicrosoftFSharpTargets Condition="'$(ImportByWildcardAfterMicrosoftFSharpTargets)' == ''"&gt;true&lt;/ImportByWildcardAfterMicrosoftFSharpTargets&gt;
      &lt;/PropertyGroup&gt;
  
      &lt;Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore\*" Condition="'$(ImportByWildcardBeforeMicrosoftFSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore')"/&gt;
  
      &lt;PropertyGroup&gt;
          &lt;MSBuildAllProjects&gt;$(MSBuildAllProjects);$(MSBuildThisFileFullPath)&lt;/MSBuildAllProjects&gt;
          &lt;DefaultLanguageSourceExtension&gt;.fs&lt;/DefaultLanguageSourceExtension&gt;
          &lt;Language&gt;F#&lt;/Language&gt;
          &lt;TargetRuntime&gt;Managed&lt;/TargetRuntime&gt;
          &lt;Tailcalls Condition="'$(Tailcalls)'==''"&gt;$(Optimize)&lt;/Tailcalls&gt;
          &lt;FrameworkRegistryBase Condition="'$(TargetFrameworkIdentifier)'=='Silverlight'"&gt;Software\Microsoft\Microsoft SDKs\$(TargetFrameworkIdentifier)&lt;/FrameworkRegistryBase&gt;
          &lt;!-- Visual studio requires a non-empty RootNamespace value for "Add New Item" to work. --&gt;
          &lt;RootNamespace Condition="'$(RootNamespace)'==''"&gt;RootNamespace&lt;/RootNamespace&gt;
          &lt;Actual32Bit Condition="'$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0'"&gt;false&lt;/Actual32Bit&gt;
          &lt;Actual32Bit Condition="!('$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0')"&gt;$(Prefer32Bit)&lt;/Actual32Bit&gt;    
      &lt;/PropertyGroup&gt;
  
      &lt;!--
        The CreateManifestResourceNames target create the manifest resource names from the .RESX
        files.
  
            [IN]
            @(EmbeddedResource) - The list of EmbeddedResource items that have been pre-processed to add metadata about resource type
                                  Expected Metadata "Type" can either be "Resx" or "Non-Resx"
  
            [OUT]
            @(EmbeddedResource) - EmbeddedResource items with metadata         
  
        For F# applications the transformation is like:
  
            Resources1.resx =&gt; Resources1 =&gt; Build into main assembly
            SubFolder\Resources1.resx =&gt; SubFolder.Resources1 =&gt; Build into main assembly
            Resources1.fr.resx =&gt; Resources1.fr =&gt; Build into satellite assembly
            Resources1.notaculture.resx =&gt; Resources1.notaculture =&gt; Build into main assembly
  
        For other project systems, this transformation may be different.
        --&gt;
      &lt;PropertyGroup&gt;
          &lt;CreateManifestResourceNamesDependsOn&gt;&lt;/CreateManifestResourceNamesDependsOn&gt;
      &lt;/PropertyGroup&gt;
      &lt;Target
          Name="CreateManifestResourceNames"
          Condition="'@(EmbeddedResource)' != ''"
          DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"
      &gt;
  
          &lt;ItemGroup&gt;
              &lt;_Temporary Remove="@(_Temporary)" /&gt;
          &lt;/ItemGroup&gt;
  
          &lt;!-- Create manifest names for culture and non-culture Resx files, and for non-culture Non-Resx resources --&gt;
          &lt;CreateFSharpManifestResourceName
                ResourceFiles="@(EmbeddedResource)"
                RootNamespace="$(RootNamespace)"
                Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx')"&gt;
  
              &lt;Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" /&gt;
  
          &lt;/CreateFSharpManifestResourceName&gt;
  
          &lt;!-- Create manifest names for all culture non-resx resources --&gt;
          &lt;CreateFSharpManifestResourceName
                ResourceFiles="@(EmbeddedResource)"
                RootNamespace="$(RootNamespace)"
                PrependCultureAsDirectory="false"
                Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx'"&gt;
  
              &lt;Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" /&gt;
  
          &lt;/CreateFSharpManifestResourceName&gt;
  
          &lt;ItemGroup&gt;
              &lt;EmbeddedResource Remove="@(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' == ''"/&gt;
              &lt;EmbeddedResource Include="@(_Temporary)" /&gt;
              &lt;_Temporary Remove="@(_Temporary)" /&gt;
          &lt;/ItemGroup&gt;
      &lt;/Target&gt;
  
      &lt;ItemGroup&gt;
          &lt;DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/&gt;
      &lt;/ItemGroup&gt;
  
      &lt;ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true' and '$(PdbFile)' != ''"&gt;
          &lt;_DebugSymbolsIntermediatePathTemporary Include="$(PdbFile)"/&gt;
          &lt;!-- Add any missing .pdb extension, as the compiler does --&gt;
          &lt;_DebugSymbolsIntermediatePath Include="@(_DebugSymbolsIntermediatePathTemporary-&gt;'%(RootDir)%(Directory)%(Filename).pdb')"/&gt;
      &lt;/ItemGroup&gt;
  
      &lt;PropertyGroup&gt;
          &lt;CoreCompileDependsOn&gt;_ComputeNonExistentFileProperty&lt;/CoreCompileDependsOn&gt;
      &lt;/PropertyGroup&gt;
  
      &lt;Target
          Name="CoreCompile"
          Inputs="$(MSBuildAllProjects);
                  @(CompileBefore);
                  @(Compile);                               
                  @(CompileAfter);
                  @(_CoreCompileResourceInputs);
                  $(ApplicationIcon);
                  $(AssemblyOriginatorKeyFile);
                  @(ReferencePath);
                  @(CompiledLicenseFile);
                  @(EmbeddedDocumentation); 
                  $(Win32Resource);
                  $(Win32Manifest);
                  @(CustomAdditionalCompileInputs);
                  $(VersionFile);
                  $(KeyOriginatorFile)"
          Outputs="@(DocFileItem);
                   @(IntermediateAssembly);
                   @(_DebugSymbolsIntermediatePath);                 
                   $(NonExistentFile);
                   @(CustomAdditionalCompileOutputs)"
          Returns=""
          DependsOnTargets="$(CoreCompileDependsOn)"
      &gt;
  
          &lt;Error
              Condition="'$(SilverlightVersion)' != '' and '$(SilverlightVersion)' != 'v5.0'"
              Text="In this version of Visual Studio, F# for Silverlight can only target Silverlight v5.0. Use a prior version of Visual Studio to target previous versions of Silverlight with F#."
          /&gt;
  
          &lt;Warning
              Condition="'$(Win32ResourceFile)' != '' "
              Text="The property &amp;lt;Win32ResourceFile&gt; has been renamed to &amp;lt;Win32Resource&gt;. Update your project file to ensure that the correct value is passed via the --win32res option to the F# compiler."
          /&gt;
  
          &lt;!-- Condition is to filter out the _CoreCompileResourceInputs so that it doesn't pass in culture resources to the compiler --&gt;
          &lt;Fsc  Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
                BaseAddress="$(BaseAddress)"
                CodePage="$(CodePage)"
                DebugSymbols="$(DebugSymbols)"
                DebugType="$(DebugType)"
                DefineConstants="$(DefineConstants)"
                DisabledWarnings="$(NoWarn)"
                DocumentationFile="$(DocumentationFile)"
                GenerateInterfaceFile="$(GenerateInterfaceFile)"
                KeyFile="$(KeyOriginatorFile)"
                LCID="$(LCID)"
                NoFramework="true"
                Optimize="$(Optimize)"
                OtherFlags="$(OtherFlags)"
                OutputAssembly="@(IntermediateAssembly)"
                PdbFile="$(PdbFile)"
                Platform="$(PlatformTarget)"
                Prefer32Bit="$(Actual32Bit)"
                References="@(ReferencePath)"
                ReferencePath="$(ReferencePath)"
                Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile);@(AdditionalEmbeddedResource)"
                Sources="@(CompileBefore);@(Compile);@(CompileAfter)"
                Tailcalls="$(Tailcalls)"
                TargetType="$(OutputType)"
                ToolExe="$(FscToolExe)"
                ToolPath="$(FscToolPath)"
                TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
                Utf8Output="$(Utf8Output)"
                VersionFile="$(VersionFile)"
                VisualStudioStyleErrors="$(VisualStudioStyleErrors)"
                WarningLevel="$(WarningLevel)"
                WarningsAsErrors="$(WarningsAsErrors)"
                Win32ManifestFile="$(Win32Manifest)"
                Win32ResourceFile="$(Win32Resource)"
                SubsystemVersion="$(SubsystemVersion)"
                HighEntropyVA="$(HighEntropyVA)"
                TargetProfile="$(TargetProfile)"
                SqmSessionGuid="$(SqmSessionGuid)"
          /&gt;
  
          &lt;ItemGroup&gt;
              &lt;_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" /&gt;
          &lt;/ItemGroup&gt;
  
      &lt;/Target&gt;
  
  
      &lt;Import Project="$(MSBuildBinPath)\Microsoft.Common.targets"/&gt;
  
    &lt;!--
        ============================================================
                                            GenerateTargetFrameworkMonikerAttribute
  
        Emit the target framework moniker attribute as  a code fragment into a temporary source file for the compiler.
  
        ============================================================
        --&gt;
  
      &lt;Target Name="GenerateTargetFrameworkMonikerAttribute" BeforeTargets="BeforeCompile" DependsOnTargets="PrepareForBuild;GetReferenceAssemblyPaths" Inputs="$(MSBuildThisFileFullPath)" Outputs="$(TargetFrameworkMonikerAssemblyAttributesPath)" Condition="'$(GenerateTargetFrameworkAttribute)' == 'true'"&gt;
  
          &lt;PropertyGroup&gt;
              &lt;!-- This attribute is only available in mscorlib v4 and later --&gt;
              &lt;AdditionalSourcesText Condition="'$(TargetFrameworkMoniker)' != '' and '$(TargetingClr2Framework)' != 'true'"&gt;
                  $(AdditionalSourcesText)
                  namespace Microsoft.BuildSettings
                  [&amp;lt;System.Runtime.Versioning.TargetFrameworkAttribute(&amp;quot;$(TargetFrameworkMoniker)&amp;quot;, FrameworkDisplayName=&amp;quot;$(TargetFrameworkMonikerDisplayName)&amp;quot;)&amp;gt;]
                  do ()
              &lt;/AdditionalSourcesText&gt;
          &lt;/PropertyGroup&gt;
  
          &lt;!-- This is a file shared between projects so we have to take care to handle simultaneous writes (by ContinueOnError)
               and a race between clean from one project and build from another (by not adding to FilesWritten so it doesn't clean) --&gt;
          &lt;WriteLinesToFile
              File="$(TargetFrameworkMonikerAssemblyAttributesPath)"
              Lines="$(AdditionalSourcesText)"
              Condition="'$(AdditionalSourcesText)' != ''"
              ContinueOnError="true"
              Overwrite="true"/&gt;
  
          &lt;ItemGroup&gt;
              &lt;CompileBefore Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" Condition="'$(AdditionalSourcesText)' != ''"/&gt;
          &lt;/ItemGroup&gt;
  
      &lt;/Target&gt;
  
      &lt;Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter\*" Condition="'$(ImportByWildcardAfterMicrosoftFSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter')"/&gt;
  
  &lt;/Project&gt;
  </code></pre>