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

Build with CodeContracts fails with dotnet build #495

Open
@johncrim

Description

@johncrim

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions