These are chat archives for Microsoft/CodeContracts

27th
Jan 2016
Sergey Teplyakov
@SergeyTeplyakov
Jan 27 2016 00:36
It is actually a really good question how to use nuget to get codecontracts properly
We have our custom tools around nuget to get nuget packages into special tools directory
for now I just not sure how we can use nuget for tools distribution
But I'll play with different required version to check how to use it.
Sergey Teplyakov
@SergeyTeplyakov
Jan 27 2016 00:51
Ok, I think I've found out the solution. Working on the new package version...
Yaakov
@yaakov-h
Jan 27 2016 01:31
I would think that a custom .targets that NuGet installs should do the trick
so Code Contracts can be installed in a project just by adding the NuGet package
Sergey Teplyakov
@SergeyTeplyakov
Jan 27 2016 01:41
The problem that nuspec file should have developmentDependency element with (I think) tools folder with binaries
What you've mentioned totally makes sense though:)
@yaakov-h Can you try to install the package once again?
this time it should not fail:)
I've tried it
and yep, the assumption was correct the package should definitely have tools folder if developmentDependency was specified
Yaakov
@yaakov-h
Jan 27 2016 02:34
package installation is working now, though it seems redundant to have Contract binaries in Bin\ and in Tools\
I tried adding the following to the csproj:
<PropertyGroup>
<CodeContractsInstallDir>..\packages\DotNet.Contracts.1.10.10126.4</CodeContractsInstallDir>
</PropertyGroup>
<Import Project="$(CodeContractsInstallDir)\MsBuild\v$(VisualStudioVersion)\Microsoft.CodeContracts.targets"/>
I get this error:
1>C:\Temp\ContractNuGetTest\packages\DotNet.Contracts.1.10.10126.4\MsBuild\v14.0\Microsoft.CodeContracts.targets(542,8): error MSB4094: "obj\Debug\Decl\ContractNuGetTest.dll;obj\Debug\Decl\ContractNuGetTest.dll" is an invalid value for the "OutputAssembly" parameter of the "Csc" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".
I wonder is maybe MSI-contracts is conflicting with NuGet-contracts?
Yaakov
@yaakov-h
Jan 27 2016 05:24
@SergeyTeplyakov Is there any reason in particular that the declarative bins are in $(IntermediateOutputDir)\Decl (obj\ somewhere) instead of $(OutputDir)\Decl (bin\ somewhere)?
Sergey Teplyakov
@SergeyTeplyakov
Jan 27 2016 06:40
@yaakov-h regarding your last question: the answer - I have no idea:)
Let's try to fix this stuff:)
We never released anything like this, and it seems that original implementation is far from perfect:(
Yaakov
@yaakov-h
Jan 27 2016 09:47
ok, I've filed my request in #348
also, looking at Microsoft.CodeContracts.targets, it doesn't look like we handle .NET 4.5.3 and 4.6.1 properly
Am I missing something, or do those fall back to .NET 3.5?
Sergey Teplyakov
@SergeyTeplyakov
Jan 27 2016 18:29
@yaakov-h regarding the targets, it seems that this is a bug and we need to fix this.
for #348: any ideas how to implement this?
Yaakov
@yaakov-h
Jan 27 2016 23:17
@SergeyTeplyakov: For #348, we currently just monkeypatch the targets (from the MSI) by doing a text replacement of "<CodeContractsDeclDir>$(IntermediateOutputPath)Decl\</CodeContractsDeclDir>" with "<CodeContractsDeclDir>$(OutputPath)\Decl\</CodeContractsDeclDir>"
so that is the simplest, but I don't know if it's something you'd want to upstream as core
also I'm not quite sure what the difference is between $(OutputPath) and $(OutDir)