I am trying to build an F# project on TeamCity. Unfortunately the build agent does not have F# installed so I have added the FSharp.Compiler.Tools nuget package to my project.
When teamcity tries to build my project I get the following error (on a brand new project created from the visual studio class library template).
[Fsc] Microsoft (R) F# Compiler version 4.1
[15:12:00][Fsc] Copyright (c) Microsoft Corporation. All Rights Reserved.
[15:12:02][Fsc]
[15:12:02][Fsc] C:\TeamCity\work\3c40581f0aabd3be\Source\MyProject\AssemblyInfo.fs(43, 1): error FS0010: Incomplete structured construct at or before this point in definition
[15:12:03][Step 8/21] Error message is logged
The project builds fine locally, both in VS2017 and using MSBuild from the command prompt.
Is there any way to fix this? I don't have access to install F# on the build agent.
Edit: This is the contents of AssemblyInfo.fs:
namespace MyProject.AssemblyInfo
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("MyProject")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("MyProject")>]
[<assembly: AssemblyCopyright("Copyright © 2017")>]
[<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("7a1189cf-d923-4367-991c-d95b1f045712")>]
// 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")>]
do
()
Ok so it seems GitVersion was being called on the teamcity agent and was appending an AssemblyInformationalVersion attribute to the end of AssemblyInfo.fs (after the do ()). Adding an empty AssemblyInformationalVersion above the do () block fixed the issue: gitversion then modified the value of the existing attribute instead of adding a new one.
Related
If I compile some code with the following:
#include <string_view>
std::string_view strv{ "Test 1" };
I get this error:
Error C2065 'string_view': undeclared identifier...
I tried some other c++17 code and not of it works.
I get the same errors if the C++ Language Standard is set to std:c++14
The Properties-->C/C++-->Command line contains /std:c++17
but the actual compiler command line that runs does not have this option set.
This is a community version of Visual Studio 2019 version 16.7.1
user dxiv pointed out the problem is in the Property pages Platform pulldown it should be set to ALL Platforms (or set C++17 individually for Win32 and x64 platforms).
We just updated .NET client libraries for TFS to version 15.131.x and which is running on the Azure DevOps 2019 server. After the update we are getting an error when calling GetItems:
using (var tfs = new TfsTeamProjectCollection(uri, cred))
{
var vs = tfs.GetService<VersionControlServer>();
var tfsWorkingFolder = ConfigurationManager.AppSettings["TFSWorkingFolder"];
var items = vs.GetItems($"{tfsWorkingFolder}", RecursionType.OneLevel);
}
The line vs.GetItems($"{tfsWorkingFolder}", RecursionType.OneLevel); gives the error
System.TypeLoadException: 'Method 'get_Properties' in type
'Microsoft.TeamFoundation.Client.HttpWebRequestWrapper' from assembly
'Microsoft.TeamFoundation.Client, Version=15.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation.'
Has the definition changed?
No, the definition not changed. That package version you are using is qualified for TFS/Azure DevOps Server version.
Actually the error your got indicates a missing dependent assembly.
System.TypeLoadException: Method ‘XXX’ in type ‘YYY’ from assembly
‘ZZZ’ does not have an implementation.
Please double check this related kind of missing dll reference in your project. Remove all the reference and re-add it again, which may do the trick.
Besides, you could also upgrade the package version Microsoft.TeamFoundationServer.Client to latest which your server support and try again.
I'm using the Microsoft.Office.Interop.Excel library (version 14.0) from an F# application and I can't seem to be able to reference some of the properties defined in Interop's interfaces/classes.
For example, if I have a Worksheet object I can't do the following:
let sht = // Get the Worksheet
sht.PageSetup.CenterHeader <- // Set the header
It can't find CenterHeader as a property of the PageSetup interface, even though it's there if I view the Interop dll in the object browser.
Just for reference, the Interop dll that I'm using is from the VS directory: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Excel.dll
Update:
I actually spoke too soon. Unfortunately the suggested solution with the cast didn't work either. VS thinks it's OK but it fails at runtime with the following error:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.IPageSetup'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208B4-0001-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
As I said in the comments, F# doesn't support type equivalence for embedded interop types, so if a C# project has Embed Interop Types enabled then the F# compiler may be unable to determine which version of the interop type to use. Since the type embedded in the C# output assembly has been stripped down to only the members used, this can make it so that the F# compiler is unable to see members that are present in the version of the type from the primary interop assembly.
The workaround is to turn off Embed Interop Types on the C# project.
This works for me:
#if INTERACTIVE
#r "office"
#r "Microsoft.Office.Interop.Excel"
#endif
open Microsoft.Office.Interop.Excel
let setCenterHeader fileName worksheet header =
let file = System.IO.FileInfo(fileName)
let excel = ApplicationClass()
try
// Make sure to use full path since this will
// be interpreted as relative to Excel's process,
// not currently executing one
let workbook = excel.Workbooks.Open(file.FullName)
let sheet = workbook.Worksheets.[worksheet] :?> Worksheet
sheet.PageSetup.CenterHeader <- header
workbook.Save()
finally
excel.Application.Quit()
setCenterHeader "TestWorksheet.xlsx" "Sheet1" "My header 1"
setCenterHeader "TestWorksheet.xlsx" "Sheet2" "My header 2"
setCenterHeader "TestWorksheet.xlsx" "Sheet3" "My header 3"
You might want to make sure you have matching versions of PIA and Office installed/used.
We're using Fake and I'd like to run DotCover after our Build target. It's alway telling me:
C:\Users\xxxxx\Dev>FAKE\tools\Fake build.fsx
F# Interactive for F# 3.1 (private)
Freely distributed under the Apache 2.0 Open Source License
For help type #help;;
> [Loading C:\Users\xxxxx\Dev\build.fsx]
build.fsx(8,1): error FS0039: The value or constructor 'DotCoverNUnit' is not defined
My short simple "test" script
#r #"FAKE/tools/FakeLib.dll"
open Fake
DotCoverNUnit dotCoverOptions nUnitOptions
What went wrong?
You need to open namespace containing DotCoverNUnit class:
open Fake.DotCover
We have a lot of Delphi Projects, when I build them before, I didn't see any error. But recently I see the following error when I build one of those projects.
D:\Delphi Projects\MySetting.pas Fatal: Could not compile used unit 'mscorlib_TLB.pas'
At first I thought some background process is using this mscorlib_TLB.pas, then I restart my computer and build it again, it still fails and gives the same error above. What is this mscorlib_TLB.pas error?
Thanks!
You have imported a COM object that is COM Callable Wrapper (CCW) around a managed (.net) object. The imported type _TLB.pas file will (sometimes needlessly) have a reference to mscorlib_TLB in its uses clause.
Delphi's type-library importer is buggy, and there are syntax errors in the auto-generated TLB pas file.
Try removing references to mscorlib_TLB in whatever unit is using it.
If the unit actually depends on something in mscorelib, then you'll have to manually fix the syntax errors in the 400kB pas file.
If you really need to use the library, you can import it using the Component::Import Component tool.
I found mscorlib_TLB alongside a COM wrapper that I built in C# a few years ago, MyComWrapper. When I copied MyComWrapper_TLB to another workstation, it was also necessary to copy mscorlib_TLB since it included type definitions required by MyComWrapper_TLB.
A re-import of the related tlb should regenerate mscorlib_TLB.pas if it can't be found. It appears I reimported the tlb on Oct 4, 2017.
Here's the prologue describing the unit:
unit mscorlib_TLB;
// ************************************************************************ //
// WARNING
// -------
// The types declared in this file were generated from data read from a
// Type Library. If this type library is explicitly or indirectly (via
// another type library referring to this type library) re-imported, or the
// 'Refresh' command of the Type Library Editor activated while editing the
// Type Library, the contents of this file will be regenerated and all
// manual modifications will be lost.
// ************************************************************************ //
// $Rev: 52393 $
// File generated on 10/4/2017 11:15:21 PM from Type Library described below.
// ************************************************************************ //
// Type Lib: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb (2)
// LIBID: {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
// LCID: 0
// Helpfile:
// HelpString: mscorlib.dll
// DepndLst:
// (1) v2.0 stdole, (C:\Windows\SysWow64\stdole2.tlb)
// Parent TypeLibrary:
// (0) v1.0 MyComWrapper, (C:\source\my-client\client-project\MyComWrapper\bin\x86\Release\MyComWrapper.tlb)