Skip to content

Commit 131dec0

Browse files
committed
Replace CodeGeneration project reference with an alternative build ordering solution
The fancy ProjectReference we were using still breaks NuGet in VS and on Linux. So we use a combination of a solution-encoded project dependency for VS, and updated build scripts for appveyor and Travis CI.
1 parent b43c6ed commit 131dec0

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
</ItemGroup>
1717
<ItemGroup>
1818
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
19-
<ProjectReference Include="..\CodeGeneration\CodeGeneration.csproj">
20-
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
21-
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
22-
<UndefineProperties>TargetFramework</UndefineProperties>
23-
<Properties>Configuration=$(CodeGeneratorConfiguration);Platform=AnyCPU</Properties>
24-
</ProjectReference>
2519
</ItemGroup>
2620
<ItemGroup>
2721
<PackageReference Include="Moq" Version="4.7.8" />

LibGit2Sharp.sln

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26228.4
4+
VisualStudioVersion = 15.0.26407.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp", "LibGit2Sharp\LibGit2Sharp.csproj", "{EE6ED99F-CB12-4683-B055-D28FC7357A34}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{6598997B-9419-4CC1-84FF-9621B555E9C0} = {6598997B-9419-4CC1-84FF-9621B555E9C0}
9+
EndProjectSection
710
EndProject
811
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp.Tests", "LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj", "{286E63EB-04DD-4ADE-88D6-041B57800761}"
912
EndProject

LibGit2Sharp/CodeGenerator.targets

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<Visible>false</Visible>
1010
</GeneratorAssemblySearchPaths>
1111
</ItemGroup>
12+
<!-- Related to https://github.com/dotnet/sdk/issues/939, this carefully written ProjectReference
13+
allows MSBuild to get the build order right without given nuget grief at the command line.
14+
Sadly, it still causes failures when run in VS or Travis CI: https://travis-ci.org/libgit2/libgit2sharp/jobs/220381005#L788
15+
So instead, we control build ordering in VS via a project dependency expressed in the SLN file,
16+
and a preliminary build of the project referenced below in Travis and AppVeyor.
1217
<ItemGroup>
1318
<ProjectReference Include="..\CodeGeneration\CodeGeneration.csproj">
1419
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -17,6 +22,7 @@
1722
<Properties>Configuration=$(CodeGeneratorConfiguration);Platform=AnyCPU</Properties>
1823
</ProjectReference>
1924
</ItemGroup>
25+
-->
2026

2127
<Target Name="GenerateCodeFirst">
2228
<PropertyGroup>

appveyor.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ nuget:
1616
disable_publish_on_pr: true
1717

1818
environment:
19+
CodeGeneratorConfiguration: release
1920
coveralls_token:
2021
secure: ixIsBslo9NheDb5lJknF58EYdgvZ0r3/L0ecRiXjfXmjHBLvoSU6/ZRwaMM+BAlG
2122
coverity_token:
@@ -72,13 +73,15 @@ install:
7273
before_build:
7374
- ps: |
7475
msbuild "$Env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp.sln" `
75-
/verbosity:quiet `
76+
/nologo /verbosity:quiet `
7677
/t:restore
7778
7879
build_script:
7980
- ps: |
81+
msbuild "$Env:APPVEYOR_BUILD_FOLDER\CodeGeneration\CodeGeneration.csproj" `
82+
/nologo /verbosity:minimal /fl /flp:verbosity=normal
8083
msbuild "$Env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp.sln" `
81-
/verbosity:minimal /fl /flp:verbosity=normal `
84+
/nologo /verbosity:minimal /fl /flp:verbosity=normal `
8285
/property:ExtraDefine="LEAKS_IDENTIFYING" `
8386
/t:build,pack
8487

build.libgit2sharp.sh

100755100644
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,19 @@ EXTRADEFINE="$1"
99
# working directory in its library search path, so it works without this value.
1010
export LD_LIBRARY_PATH=.
1111

12-
dotnet restore
13-
dotnet build LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj -c Release -f netcoreapp1.0 /property:ExtraDefine="$EXTRADEFINE"
14-
dotnet test LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj -c Release -f netcoreapp1.0 --no-build
12+
# Build release for the code generator and the product itself.
13+
export Configuration=release
14+
export CodeGeneratorConfiguration=release
15+
16+
# Build CodeGeneration first. See CodeGenerator.targets for why this has to be
17+
# a preliminary step.
18+
dotnet restore CodeGeneration
19+
dotnet build CodeGeneration
20+
21+
# On linux we don't pack because we can't build for net40.
22+
# We just build for CoreCLR and run tests for it.
23+
dotnet restore LibGit2Sharp.Tests
24+
dotnet build LibGit2Sharp.Tests -f netcoreapp1.0 /property:ExtraDefine="$EXTRADEFINE"
25+
dotnet test LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj -f netcoreapp1.0 --no-build
1526

1627
exit $?

0 commit comments

Comments
 (0)