microsoft / CodeContracts

Source code for the CodeContracts tools for .NET
Other
882 stars 150 forks source link

Can't build CodeContracts - installer building fails #375

Open Dennis-Petrov opened 8 years ago

Dennis-Petrov commented 8 years ago

Hi everyone.
I've forked CC from master branch yesterday, and can't build it via batch file. I'm running buildcc.bat from MSBuild command prompt (VS2015) and getting this error:

Build FAILED.

"D:\Projects\Research\CodeContracts\Microsoft.Research\ManagedContract.Setup\bu ildMSI10.xml" (All target) (1) -> (CreateVersionFile target) -> EXEC : error : unknown switch '?' [D:\Projects\Research\CodeContracts\Microso ft.Research\ManagedContract.Setup\buildMSI10.xml] D:\Projects\Research\CodeContracts\Microsoft.Research\ManagedContract.Setup\b uildMSI10.xml(299,5): error MSB3073: The command "git update-index --assume-unc hanged ..\common\include\version.cs" exited with code 129.

0 Warning(s)
2 Error(s)

My machine has git 2.7.0.2 x64 installed - I had to install it, because for now it is impossible to build without git at all.

Maybe, README.MD misses some details about building process?

SergeyTeplyakov commented 8 years ago

You need to use VS2013. VS2015 is still not supported (the error message looks weird, but even if this one will pass you'll face another issue with VS2015)..

hubuk commented 8 years ago

I was able to reproduce the issue. The error message is indeed weird:

  git update-index --assume-unchanged ..\common\include\version.cs
EXEC : error : unknown switch '?' [D:\Github\Microsoft\CodeContracts\Microsoft.Research
\ManagedContract.Setup\buildMSI10.xml]
  usage: git update-index [<options>] [--] [<file>...]

      (...)
      --assume-unchanged    mark files as "not changing"
      (...)

When running on dev cmd for VS2013 with the same version of git (2.7.0.2 x64) everything works fine.

Dennis-Petrov commented 8 years ago

@SergeyTeplyakov: well... I've built CC about 3 weeks ago successfully from master branch using VS 2015. Moreover, I was able to build it from unpacked ZIP-archive, without git installed, while now I had to clone git repository locally.

Definitely something was changed in build scripts (maybe, somewhere else, this is just an assumption). Also note, that CC libraries are built just fine. The case is in installer. Are you sure, that the problem is in VS (MSBuild version)?

yaakov-h commented 8 years ago

VS2013 Developer Command Prompt plus Git in my path (I think latest Git for Windows) works fine for me, but I am also building from a cloned repository.

Could it be that git update-index fails in odd ways if it's not running from a git repo?

SergeyTeplyakov commented 8 years ago

@Dennis-Petrov Now, it is clear that something is broken.

SergeyTeplyakov commented 8 years ago

But the question is, why the failure is happening on the git command? I'll try to check it tomorrow (almost 1 a.m. in the morning right now in my time zone).

Dennis-Petrov commented 8 years ago

@SergeyTeplyakov: I've figured out it. :) There's a typo here (buildMSI10.xml):

<Exec Command="git update-index -–assume-unchanged @(VersionFile)"/>

The second dash before "assume" has 0x2013 code instead of 0x2D ("minus" key on keyboard). Looks like there several such typos there. These ones too:

<Exec Command="git update-index -–assume-unchanged ..\ContractAdornments\Extension\source.extension.vsixmanifest"/>
<Exec Command="git update-index -–assume-unchanged VSIX\VS10.extension.vsixmanifest"/>
<Exec Command="git update-index -–assume-unchanged VSIX\VS11.extension.vsixmanifest"/>
<Exec Command="git update-index -–assume-unchanged VSIX\VS12.extension.vsixmanifest"/>
<Exec Command="git update-index -–assume-unchanged VSIX\VS14.extension.vsixmanifest"/>
hubuk commented 8 years ago

My fault. PR created.

yaakov-h commented 8 years ago

Oh good catch, that's a Unicode EN-Dash.

So the new question is: Why does it work for me/AppVeyor/etc.? A less pedantic versions of Git?

Dennis-Petrov commented 8 years ago

@yaakov-h: also, why it does require git / git repo at all now? Do we need to improve README.MD?

yaakov-h commented 8 years ago

No idea, that's a question for @hubuk from #328.

hubuk commented 8 years ago

@yaakov-h @Dennis-Petrov I used git update-index command to hide all changes made by build process to files in repository (version.cs and vsix manifests). It might also be achieved by a copy of a template file with entry in .gitignore but it would not work inside Visual Studio. Most of the time I work with CodeContracts directly from git repository (I assume that most of us do). In such case executing buildCC.bat produced changes for files I did not want to commit. Using git add . was pretty hard. #328 was addressing this issue but I did not covered a situation when the source code is not on git repository or git is not available.

First commit in #376 fixes an invalid dash character. I was not building CC from VS2015 command prompt so did not encountered the issue before (command prompt for VS2013 works just fine even for the same version of git, so there may be something changed in MSBuild 14.0 regarding encoding). Second commit in #376 adds condition before calling each git update-index. The condition is an error code returned by git rev-parse. Value of 0 means that git is available (command was run) and current directory is under git control.

I would like to ask you to take a look at this PR in case there are some other cases I not covered.

Dennis-Petrov commented 8 years ago

@hubuk: Looks like there's another issue. I've finally build it, but without VB stuff. Literally, I had to remove these projects from solution and their output from WiX script:

Microsoft.VisualBasic.Compatibility10 Microsoft.VisualBasic10

because both of them can't resolve reference to Microsoft.VisualBasic.dll during build.

hubuk commented 8 years ago

@Dennis-Petrov Could you provide a build log file?

Dennis-Petrov commented 8 years ago

Sure. Added attachment.

build.zip

hubuk commented 8 years ago

@Dennis-Petrov As @SergeyTeplyakov wrote, building from Visual Studio 2015 is not quite finished yet. Even if it was working before it produced invalid bits due to some rewriter issues with Roslyn (parts of CC are being rewriten too). Anyway, this is an easily reproducible on VS2015 command prompt build. It would be best to raise a separate issue for full VS2015 support with working tests.

Dennis-Petrov commented 8 years ago

Shouldn't this issue be closed, since we're waiting for complete VS2015 support?

hubuk commented 8 years ago

@Dennis-Petrov I think this issue may remain opened as a reference. But it is up to you.

johncrim commented 7 years ago

I've sent a PR with a couple fixes that allow me to build the project using VS 2015. The PR is associated with #471.