I am trying to deploy my first application hosted on AppHarbor and have encountered a problem with my build. Everything builds fine until code contracts try to rewrite assemblies. Error in the log:
CodeContractsRunCodeAnalysisInternal: CodeContracts: Task manager is unavailable (unable to run in background). CodeContracts: ABC: Run static contract analysis. CodeContracts: ABC: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. CodeContracts: ABC: at Microsoft.Research.CodeAnalysis.SQLCacheDataAccessor.GetMetadataOrNull(String key, Boolean silent) CodeContracts: ABC: at Microsoft.Research.CodeAnalysis.CacheManager`11.TestCache() CodeContracts: ABC: at Microsoft.Research.CodeAnalysis.CacheManager`11..ctor(Dictionary`2 methodAnalyses, Dictionary`2 classAnalyses, GeneralOptions options) CodeContracts: ABC: at Microsoft.Research.CodeAnalysis.CacheManager`11.Create(Dictionary`2 dictionary, Dictionary`2 dictionary_2, GeneralOptions generalOptions) CodeContracts: ABC: at Microsoft.Research.CodeAnalysis.Clousot.TypeBinder`9..ctor(String[] args, IDecodeMetaData`9 mdDecoder, IDecodeContracts`5 contractDecoder, IDictionary assemblyCache, Action`3 setTargetPlatform, IOutputFullResultsFactory`2 externalOutputFactory) CodeContracts: ABC: at Microsoft.Research.CodeAnalysis.Clousot.ClousotMain[Local,Parameter,Method,Field,Property,Event,Type,Attribute,Assembly](String[] args, IDecodeMetaData`9 mdDecoder, IDecodeContracts`5 contractDecoder, IDictionary assemblyCache, Action`3 setTargetPlatform) CodeContracts: ABC: at Microsoft.Research.CodeAnalysis.CCI1Driver.Main(String[] args) CodeContracts: ABC: CodeContracts: ABC: Static contract analysis done.
I know that when creating locally with Visual Studio, the contract code runs in the background thread. Perhaps AppHarbor does not allow creating such streams for this? But what error is missing in the System.Data.SqlServerCe.dll? My code is sure that it is not using it, but maybe contracts with MS code are being executed?
Itβs just interesting if someone successfully deployed the code with the code contracts in it in AppHarbor, and if so, what did you do to make it work? It may be necessary for SQL Server CE to install AppHarbor for the code contracts to work. Oh, and my assembly does not create a reference assembly of the contract code, it just tries to do a static check and does a rewrite to do runtime checks.
Finally, I tried to disable code contracts from AppHarbor.sln, but this option is a project setting, not a solution setting, so it also disables them for my regular solution file.