我在使用MSBuild构建解决方案时遇到问题。
在我的解决方案中,我有F#项目,我已经添加了AssemblyInfo.fs文件,这样的文件如下所示:
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")>]
()
当我在Visual Studio 2012中编译我的解决方案时,我没有任何问题。所有程序集都构建有关于版本的很好的信息。
问题在于TFS Builds(我有TFS 2012)。我的解决方案的构建总是失败。该错误起源于CoreCompile fsc.exe步骤,它与AssemblyInfo.fs文件有关:
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.
我不知道为什么MSBuild中的fsc.exe对我的AssemblyInfo.fs文件有问题。
更奇怪的是,当我使用“VS2012的开发人员命令提示符”并执行完全相同的MSBuild或fsc.exe命令时,一切都很顺利。我没有任何错误。所以看起来TFS Build有一些奇怪的问题,即使我运行相同的命令,我也无法在我的机器上重现。
感谢您的帮助!