MSBuild F# project with AssemblyInfo.fs file. Error during CoreCompile with fsc.exe
Asked Answered
P

0

6

I have problem with building my solution by MSBuild.

In my solution I have the F# projects to which I have added the AssemblyInfo.fs files, such file looks as follows:

namespace namespaceName

open System.Reflection
open System.Runtime.CompilerServices
open System.Runtime.InteropServices

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[<assembly: AssemblyTitle("assemblyName")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("assemblyName")>]
[<assembly: AssemblyCopyright("Copyright ©  2013")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[<assembly: ComVisible(false)>]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[<assembly: Guid("9b60cdeb-57b8-4e08-b713-1be614a449cd")>]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the ‘*’ as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[<assembly: AssemblyVersion("1.0.0.0")>]
[<assembly: AssemblyFileVersion("1.0.0.0")>]
()

When I compile my solution in Visual Studio 2012 I do not have any problems. All assemblies are build with a nice information about version.

The problem is with the TFS Builds (I have the TFS 2012). The build of my solution always fails. The error origins in the CoreCompile fsc.exe step and it is about the AssemblyInfo.fs file:

Project "D:\path\projectMaster.csproj" (40) is building "D:\path\projectName.fsproj" (41) on node 1 (default targets).
PrepareForBuild:
  Creating directory "obj\Release\".
  Creating directory "bin\Release\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\fsc.exe -o:obj\Release\projectName.dll --debug:pdbonly --noframework --define:TRACE --doc:bin\Release\projectName.XML --optimize+ -r:D:\path\r1.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\v4.0\FSharp.Core.dll" -r:D:\path\r2.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Numerics.dll" --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors --highentropyva- "C:\Users\userName\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.fs" folder1\file1.fs folder1\file2.fs folder2\file1.fs 

D:\path\projectName\AssemblyInfo.fs(37,10): error FS0010: Unexpected symbol ':' in expression. Expected ']' or other token. [D:\path\projectName\projectName.fsproj]

D:\path\projectName\AssemblyInfo.fs(37,1): error FS0598: Unmatched '[' [D:\path\projectName\projectName.fsproj]

D:\path\projectName\AssemblyInfo.fs(40,1): error FS0010: Incomplete structured construct at or before this point in implementation file [D:\path\projectName\projectName.fsproj]
Done Building Project "D:\path\projectName\projectName.fsproj" (default targets) -- FAILED.

I have no idea why the fsc.exe in MSBuild have problem with my AssemblyInfo.fs files.

What is more strange, when I use the "Developer Command Prompt for VS2012" and I execute exactly the same MSBuild or fsc.exe commands everything goes fine. I do not have any errors. So it seems that the TFS Build have some strange problems which I am not able to reproduce on my machines even if I run the same commands.

Thank you for any help!

Phippen answered 3/9, 2013 at 6:22 Comment(4)
It seems to be having a problem with attribute (specifically with an explicit target). Therefore step one would be to add another, unrelated to assembly properties, attribute the start of this file (or one earlier in the compilation).Stearne
Additionally: try putting all of these attributes and the (no-op) expression they apply to into a module: namespaces cannot directly contain executable code: I'm surprised this works at all.Stearne
I am not sure if putting this stuff into a module will change anything. There is a Visual Studio extension with F# AssemblyInfo template which is also using a namespace, so I believe that this is a proper way (visualstudiogallery.msdn.microsoft.com/…). Why are you surprised that this works?Phippen
Because it didn't work for me :-). (But then I was also using a literal to avoid repeating the version string.)Stearne

© 2022 - 2024 — McMap. All rights reserved.