Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Build with CodeContracts fails with dotnet build #495

Open
johncrim opened this issue Sep 25, 2017 · 0 comments · May be fixed by #496
Open

Build with CodeContracts fails with dotnet build #495

johncrim opened this issue Sep 25, 2017 · 0 comments · May be fixed by #496

Comments

@johncrim
Copy link

By manually adding imports and msbuild properties (b/c no IDE support in VS 2017), ccrewrite works on netcoreapp and netstandard projects (only when portable PDBs are not used).

Running the build using msbuild /t:build works. Running the build using dotnet build fails:

dotnet build /v:normal
Build started 2017-09-25 9:06:34 AM
...
       CreateCodeContractReferenceAssembly:
         "C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrefgen.exe" "@obj\Debug\netstandard2.0\MyProject.ccrefgen.rsp"
         elapsed time: 881.9998ms
       CodeContractRewrite:
         "C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite.exe" "@MyProject.ccrewrite.rsp"
                There were errors reported in Tv.Web.Upfront.Model's metadata.
                Exception of type 'System.OutOfMemoryException' was thrown.
     1>ccrewrite : error : Foxtrot:     There were errors reported in Tv.Web.Upfront.Model's metadata. [C:\src\my\project\MyProject.csproj]
                Exception of type 'System.OutOfMemoryException' was thrown.
         elapsed time: 61.4774ms
     1>C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v15.0\Microsoft.CodeContracts.targets(275,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite.exe" "@MyProject.ccrewrite.rsp"" exited with code -1. [C:\src\my\project\MyProject.csproj]
     1>Done Building Project "C:\src\my\project\MyProject.csproj" (Build target(s)) -- FAILED.

Build FAILED.

The root cause is this block of the Microsoft.CodeContracts.targets file:
https://github.com/Microsoft/CodeContracts/blob/master/Microsoft.Research/ManagedContract.Setup/MSBuild/v15.0/Microsoft.CodeContracts.targets#L292

Target GetFrameworkSdkPath, and sn.exe don't exist in the dotnet build system.

johncrim pushed a commit to johncrim/CodeContracts that referenced this issue Sep 25, 2017
Disable sn.exe in VS 2017 code contracts targets, to allow code contracts to build within "dotnet build" or "dotnet test".

.NET core does not support sn.exe nor `GetFrameworkSdkPath`
@johncrim johncrim linked a pull request Sep 25, 2017 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant