1

I'm trying to learn my way around the Microsoft Code Contracts libraries, and I have the following simple function:

internal static Engine CreateBuildEngine(Microsoft.Build.Framework.ILogger logger)
{
    Contract.Requires( logger != null );

    var engine = new Engine { DefaultToolsVersion = "3.5" };
    engine.RegisterLogger(logger);
    return engine;
}

When attempting to compile this, the contracts static compiler throws up the following warning message:

warning : contracts: Assembly load resulted in metadata import 'Could not resolve member reference: Microsoft.Build.BuildEngine.Engine::set_DefaultToolsVersion.'

and then promptly gives up (and doesn't attempt to do any further contract processing). If I remove the code which sets DefaultToolsVersion then the contract verifier works correctly, however this is rather pointless as it will cause the code to be incorrect.

I can't find any mention of this on google... Is there some way that I can fix this, or is it just a bug in the contracts library? (admittedly it's in pre-release status)

Thanks

John Gietzen
  • 48,783
  • 32
  • 145
  • 190
Orion Edwards
  • 121,657
  • 64
  • 239
  • 328
  • Are you using the latest CC? I just pasted your code into an empty project and it compiles fine. – porges Jan 19 '11 at 10:07
  • Oh dear, just realised I had my StackOverflow filtered to "unanswered" questions, have been answering old questions for a while now... :P – porges Jan 19 '11 at 10:21

0 Answers0