@@ -29,7 +29,6 @@ class Build : NukeBuild
2929
3030 AbsolutePath SourceDirectory => RootDirectory / "src" ;
3131 AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts" ;
32- AbsolutePath PackageRestoreDirectory => SourceDirectory / "packages" ;
3332 Project libplctag => Solution . GetProject ( "libplctag" ) ;
3433 Project libplctag_NativeImport => Solution . GetProject ( "libplctag.NativeImport" ) ;
3534
@@ -39,7 +38,6 @@ class Build : NukeBuild
3938 {
4039 SourceDirectory . GlobDirectories ( "**/bin" , "**/obj" )
4140 . Concat ( ArtifactsDirectory )
42- . Concat ( PackageRestoreDirectory )
4341 . ForEach ( dir =>
4442 {
4543 Log . Debug ( "Deleting {0}" , dir ) ;
@@ -73,92 +71,8 @@ class Build : NukeBuild
7371 } ) ;
7472
7573
76- Target TestLibplctagNativeImport => _ => _
77- . DependsOn ( PackLibplctagNativeImport )
78- . DependsOn ( PackLibplctag )
79- . Executes ( ( ) =>
80- {
81-
82- // This nuget.config file ensures that libplctag and libplctag.NativeImport are restored from the
83- // newly created and packed packages on disk, but still allows all other packages to be
84- // downloaded from the remote nuget feed.
85- var nuget_config_contents = $ """
86- <?xml version="1.0" encoding="utf-8"?>
87- <configuration>
88- <packageSources>
89- <clear />
90- <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
91- <add key="buildArtifacts" value="{ ArtifactsDirectory } " />
92- </packageSources>
93-
94- <packageSourceMapping>
95- <packageSource key="nuget.org">
96- <package pattern="Microsoft.*" />
97- <package pattern="System.*" />
98- <package pattern="xunit*" />
99- <package pattern="coverlet*" />
100- <package pattern="runtime.*" />
101- <package pattern="newtonsoft.json" />
102- <package pattern="nuget.*" />
103- <package pattern="mstest.*" />
104- </packageSource>
105- <packageSource key="buildArtifacts">
106- <package pattern="libplctag" />
107- <package pattern="libplctag.NativeImport" />
108- </packageSource>
109- </packageSourceMapping>
110- </configuration>
111- """ ;
112-
113- var netCoreDirect = Solution . GetProject ( "libplctag.NativeImport.Tests.NetCore.DirectDependency" ) ;
114- var netCoreTransitive = Solution . GetProject ( "libplctag.NativeImport.Tests.NetCore.TransitiveDependency" ) ;
115- var netFrameworkDirect = Solution . GetProject ( "libplctag.NativeImport.Tests.NetFramework.DirectDependency" ) ;
116- var netFrameworkTransitive = Solution . GetProject ( "libplctag.NativeImport.Tests.NetFramework.TransitiveDependency" ) ;
117-
118- var nugetConfigPath = Path . GetTempFileName ( ) + ".nuget.config" ;
119- File . WriteAllText ( nugetConfigPath , nuget_config_contents ) ;
120-
121- NetCoreInstallRestoreBuildTest ( netCoreDirect , isTransitive : false , nugetConfigPath ) ;
122- NetCoreInstallRestoreBuildTest ( netCoreTransitive , isTransitive : true , nugetConfigPath ) ;
123- // Future - figure out how to test for packges.config projects
124- // The issue I ran into is that there is no way to add packages using the CLI
125- // dotnet CLI does not work for packages.config projects - https://github.com/dotnet/sdk/issues/7922
126- // Nuget does not modify project/solution files - https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-nuget-cli#install-a-package
127- // And this is known to not be supported - https://github.com/NuGet/Home/issues/1512
128-
129- File . Delete ( nugetConfigPath ) ;
130-
131- } ) ;
132-
133- void NetCoreInstallRestoreBuildTest ( Project proj , bool isTransitive , string nugetConfigPath )
134- {
135- DotNetRestore ( s => s
136- . SetProjectFile ( proj )
137- . SetPackageDirectory ( PackageRestoreDirectory )
138- . SetConfigFile ( nugetConfigPath )
139- ) ;
140-
141- var libplctagVersion = libplctag . GetProperty ( "version" ) ;
142- var libplctagNativeImportVersion = libplctag_NativeImport . GetProperty ( "version" ) ;
143-
144- DotNet ( $ "add { proj . Path } package { libplctag_NativeImport . Name } -s { ArtifactsDirectory } --version { libplctagNativeImportVersion } --package-directory { PackageRestoreDirectory } ") ;
145-
146- if ( isTransitive )
147- DotNet ( $ "add { proj . Path } package { libplctag . Name } -s { ArtifactsDirectory } --version { libplctagVersion } --package-directory { PackageRestoreDirectory } ") ;
148-
149- DotNetBuild ( s => s
150- . SetProjectFile ( proj )
151- . SetConfiguration ( Configuration )
152- . SetNoRestore ( true )
153- ) ;
154-
155- DotNetTest ( s => s
156- . SetProjectFile ( proj )
157- . SetNoRestore ( true )
158- ) ;
159- }
160-
16174 Target PackLibplctag => _ => _
75+ . DependsOn ( Compile )
16276 . Executes ( ( ) =>
16377 {
16478 DotNetPack ( s => s
@@ -186,7 +100,8 @@ void NetCoreInstallRestoreBuildTest(Project proj, bool isTransitive, string nuge
186100
187101 Target ReleaseAll => _ => _
188102 . DependsOn ( TestLibplctag )
189- . DependsOn ( TestLibplctagNativeImport )
103+ . DependsOn ( PackLibplctagNativeImport )
104+ . DependsOn ( PackLibplctag )
190105 . Requires ( ( ) => NugetApiUrl )
191106 . Requires ( ( ) => NugetApiKey )
192107 . Requires ( ( ) => Configuration . Equals ( Configuration . Release ) )
0 commit comments