Skip to content

Commit 67fe8ce

Browse files
committed
Update Projects static initializing even further, unit tests all pass now
1 parent 719e7a4 commit 67fe8ce

File tree

2 files changed

+73
-57
lines changed

2 files changed

+73
-57
lines changed

.paket/Paket.Restore.targets

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@
1111
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
1212
<PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
1313
<PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath>
14+
<PaketBootstrapperStyle>classic</PaketBootstrapperStyle>
15+
<PaketBootstrapperStyle Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')">proj</PaketBootstrapperStyle>
16+
<PaketExeImage>assembly</PaketExeImage>
17+
<PaketExeImage Condition=" '$(PaketBootstrapperStyle)' == 'proj' ">native</PaketExeImage>
1418
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
1519
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
1620
<!-- Paket command -->
21+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket')">$(PaketToolsPath)paket</PaketExePath>
1722
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
18-
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
19-
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
20-
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
2123

22-
<!-- .net core fdd -->
23-
<_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension>
24-
<PaketCommand Condition=" '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</PaketCommand>
24+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' ">$(PaketToolsPath)paket.exe</PaketExePath>
25+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND '$(PaketExeImage)' == 'assembly' ">$(PaketToolsPath)paket.exe</PaketExePath>
26+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND '$(PaketExeImage)' == 'native' ">$(PaketToolsPath)paket</PaketExePath>
2527

26-
<!-- no extension is a shell script -->
27-
<PaketCommand Condition=" '$(_PaketExeExtension)' == '' ">"$(PaketExePath)"</PaketCommand>
28+
<!-- Paket command -->
29+
<_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension>
30+
<PaketCommand Condition=" '$(PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</PaketCommand>
31+
<PaketCommand Condition=" '$(PaketCommand)' == '' AND '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
32+
<PaketCommand Condition=" '$(PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
33+
<PaketCommand Condition=" '$(PaketCommand)' == '' AND '$(OS)' != 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
2834

2935
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
3036
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
@@ -38,7 +44,11 @@
3844
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
3945
</PropertyGroup>
4046

41-
<Target Name="PaketRestore" Condition="'$(PaketRestoreDisabled)' != 'True'" BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" >
47+
<Target Name="PaketBootstrapping" Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')">
48+
<MSBuild Projects="$(PaketToolsPath)paket.bootstrapper.proj" Targets="Restore" />
49+
</Target>
50+
51+
<Target Name="PaketRestore" Condition="'$(PaketRestoreDisabled)' != 'True'" BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" DependsOnTargets="PaketBootstrapping">
4252

4353
<!-- Step 1 Check if lockfile is properly restored -->
4454
<PropertyGroup>
@@ -72,9 +82,12 @@
7282
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
7383
</PropertyGroup>
7484

85+
<PropertyGroup Condition="'$(PaketPropsVersion)' != '5.174.2' ">
86+
<PaketRestoreRequired>true</PaketRestoreRequired>
87+
</PropertyGroup>
7588

7689
<!-- Do a global restore if required -->
77-
<Exec Command='$(PaketBootStrapperCommand)' Condition="Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
90+
<Exec Command='$(PaketBootStrapperCommand)' Condition=" '$(PaketBootstrapperStyle)' == 'classic' AND Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
7891
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />
7992

8093
<!-- Step 2 Detect project specific changes -->
@@ -93,7 +106,7 @@
93106
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketOriginalReferencesFilePath>
94107
<!-- paket.references -->
95108
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\paket.references</PaketOriginalReferencesFilePath>
96-
109+
97110
<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
98111
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
99112
<PaketRestoreRequired>true</PaketRestoreRequired>
@@ -132,11 +145,11 @@
132145
<Error Condition=" '$(DoAllResolvedFilesExist)' != 'true' AND '$(ResolveNuGetPackages)' != 'False' " Text="One Paket file '@(PaketResolvedFilePaths)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />
133146

134147
<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
135-
<ReadLinesFromFile Condition="'@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" ><!--Condition="Exists('%(PaketResolvedFilePaths.Identity)')"-->
148+
<ReadLinesFromFile Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" >
136149
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
137150
</ReadLinesFromFile>
138151

139-
<ItemGroup Condition=" '@(PaketReferencesFileLines)' != '' " >
152+
<ItemGroup Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketReferencesFileLines)' != '' " >
140153
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
141154
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
142155
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>

src/Tests/Tests.Domain/Project.cs

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,6 @@ public class Project
1515
{
1616
public static string TypeName = "project";
1717

18-
public static readonly Project Instance = new Project
19-
{
20-
Name = Projects.First().Name,
21-
LeadDeveloper = new Developer() { FirstName = "Martijn", LastName = "Laarman" },
22-
StartedOn = new DateTime(2015, 1, 1),
23-
DateString = new DateTime(2015, 1, 1).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"),
24-
Location = new SimpleGeoPoint { Lat = 42.1523, Lon = -80.321 },
25-
SourceOnly = TestConfiguration.Instance.Random.SourceSerializer ? new SourceOnlyObject() : null
26-
};
27-
28-
public static readonly string Routing = Instance.Name;
29-
30-
private static readonly object InstanceAnonymousDefault = new
31-
{
32-
name = Projects.First().Name,
33-
type = TypeName,
34-
join = Instance.Join.ToAnonymousObject(),
35-
state = "BellyUp",
36-
visibility = "Public",
37-
startedOn = "2015-01-01T00:00:00",
38-
lastActivity = "0001-01-01T00:00:00",
39-
numberOfContributors = 0,
40-
dateString = new DateTime(2015, 1, 1).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"),
41-
leadDeveloper = new { gender = "Male", id = 0, firstName = "Martijn", lastName = "Laarman" },
42-
location = new { lat = Instance.Location.Lat, lon = Instance.Location.Lon }
43-
};
44-
45-
private static readonly object InstanceAnonymousSourceSerializer = new
46-
{
47-
name = Projects.First().Name,
48-
type = TypeName,
49-
join = Instance.Join.ToAnonymousObject(),
50-
state = "BellyUp",
51-
visibility = "Public",
52-
startedOn = "2015-01-01T00:00:00",
53-
lastActivity = "0001-01-01T00:00:00",
54-
numberOfContributors = 0,
55-
dateString = new DateTime(2015, 1, 1).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"),
56-
leadDeveloper = new { gender = "Male", id = 0, firstName = "Martijn", lastName = "Laarman" },
57-
location = new { lat = Instance.Location.Lat, lon = Instance.Location.Lon },
58-
sourceOnly = new { notWrittenByDefaultSerializer = "written" }
59-
};
60-
61-
6218
public IEnumerable<string> Branches { get; set; }
6319
public IList<Tag> CuratedTags { get; set; }
6420
public string DateString { get; set; }
@@ -121,8 +77,55 @@ [StringEnum] [JsonConverter(typeof(StringEnumConverter))]
12177
{ "color", new[] { "red", "blue", "green", "violet", "yellow" }.Take(Gimme.Random.Number(1, 4)) }
12278
}
12379
});
80+
12481
public static IList<Project> Projects { get; } = Generator.Clone().Generate(100);
82+
12583
public static Project First { get; } = Projects.First();
84+
85+
public static readonly Project Instance = new Project
86+
{
87+
Name = Projects.First().Name,
88+
LeadDeveloper = new Developer() { FirstName = "Martijn", LastName = "Laarman" },
89+
StartedOn = new DateTime(2015, 1, 1),
90+
DateString = new DateTime(2015, 1, 1).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"),
91+
Location = new SimpleGeoPoint { Lat = 42.1523, Lon = -80.321 },
92+
SourceOnly = TestConfiguration.Instance.Random.SourceSerializer ? new SourceOnlyObject() : null
93+
};
94+
95+
public static readonly string Routing = Instance.Name;
96+
97+
private static readonly object InstanceAnonymousDefault = new
98+
{
99+
name = Projects.First().Name,
100+
type = TypeName,
101+
join = Instance.Join.ToAnonymousObject(),
102+
state = "BellyUp",
103+
visibility = "Public",
104+
startedOn = "2015-01-01T00:00:00",
105+
lastActivity = "0001-01-01T00:00:00",
106+
numberOfContributors = 0,
107+
dateString = new DateTime(2015, 1, 1).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"),
108+
leadDeveloper = new { gender = "Male", id = 0, firstName = "Martijn", lastName = "Laarman" },
109+
location = new { lat = Instance.Location.Lat, lon = Instance.Location.Lon }
110+
};
111+
112+
private static readonly object InstanceAnonymousSourceSerializer = new
113+
{
114+
name = Projects.First().Name,
115+
type = TypeName,
116+
join = Instance.Join.ToAnonymousObject(),
117+
state = "BellyUp",
118+
visibility = "Public",
119+
startedOn = "2015-01-01T00:00:00",
120+
lastActivity = "0001-01-01T00:00:00",
121+
numberOfContributors = 0,
122+
dateString = new DateTime(2015, 1, 1).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"),
123+
leadDeveloper = new { gender = "Male", id = 0, firstName = "Martijn", lastName = "Laarman" },
124+
location = new { lat = Instance.Location.Lat, lon = Instance.Location.Lon },
125+
sourceOnly = new { notWrittenByDefaultSerializer = "written" }
126+
};
127+
128+
126129
// @formatter:on — enable formatter after this line
127130
}
128131

0 commit comments

Comments
 (0)