Skip to content

Commit

Permalink
Migration to .NET 5
Browse files Browse the repository at this point in the history
- Replaced costura with .NET single file publish.
- Fixed package source ordering in Nuget.PackageManagement-v5.11.0.
  • Loading branch information
maraf committed Nov 1, 2021
1 parent 4202c83 commit ab15af8
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 100 deletions.
52 changes: 0 additions & 52 deletions build/Wpf.Build.targets

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<Description>NuGet-based Plugin Manager for Git Extensions</Description>
<PackageTags>GitExtensions</PackageTags>
<PackageProjectUrl>https://github.com/gitextensions/gitextensions.pluginmanager</PackageProjectUrl>
Expand All @@ -12,12 +13,14 @@

<PropertyGroup>
<PackageManagerTargetPath>PackageManager\PackageManager.UI.exe</PackageManagerTargetPath>
<PackageManagerSourcePath>..\PackageManager.UI\bin\$(Configuration)\$(TargetFramework)\PackageManager.UI.exe</PackageManagerSourcePath>
<PackageManagerSourcePath>..\PackageManager.UI\bin\Release\$(TargetFramework)\publish\PackageManager.UI.exe</PackageManagerSourcePath>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitExtensions.Extensibility" Version="0.1.*" />
<PackageReference Include="GitExtensions.Extensibility" Version="0.2.*" />
<PackageReference Include="System.ComponentModel.Composition" Version="5.0.0" />
<PackageReference Include="System.Resources.Extensions" Version="4.6.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -34,8 +37,6 @@
<Reference Include="ResourceManager">
<HintPath>$(GitExtensionsPath)\ResourceManager.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</metadata>
<files>
<file src="../../LICENSE.md" target="/" />
<file src="bin/$configuration$/net461/GitExtensions.PluginManager.dll" target="lib/" />
<file src="bin/$configuration$/net461/PackageManager/PackageManager.UI.exe" target="lib/PackageManager/" />
<file src="bin/$configuration$/net5.0-windows/GitExtensions.PluginManager.dll" target="lib/" />
<file src="bin/$configuration$/net5.0-windows/PackageManager/PackageManager.UI.exe" target="lib/PackageManager/" />
</files>
</package>
2 changes: 1 addition & 1 deletion src/GitExtensions.PluginManager/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Plugin : GitPluginBase
public const string PackageId = @"GitExtensions.PluginManager";
public const string GitExtensionsRelativePath = @"GitExtensions.exe";
public const string PluginManagerRelativePath = @"PackageManager\PackageManager.UI.exe";
public static readonly List<string> FrameworkMonikers = new List<string>() { "net461", "any", "netstandard2.0" };
public static readonly List<string> FrameworkMonikers = new List<string>() { "net5.0", "any", "netstandard2.0" };

internal PluginSettings Configuration { get; private set; }

Expand Down
2 changes: 1 addition & 1 deletion src/GitExtensions.PluginManager/PluginSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class PluginSettings : IEnumerable<ISetting>
/// <summary>
/// Gets current value of <see cref="CloseInstancesProperty"/>.
/// </summary>
public bool CloseInstances => source.GetValue(CloseInstancesProperty.Name, CloseInstancesProperty.DefaultValue, t => bool.Parse(t));
public bool CloseInstances => source.GetBool(CloseInstancesProperty.Name, CloseInstancesProperty.DefaultValue);

public PluginSettings(ISettingsSource source)
{
Expand Down
4 changes: 0 additions & 4 deletions src/PackageManager.Cli/FodyWeavers.xml

This file was deleted.

5 changes: 2 additions & 3 deletions src/PackageManager.Cli/PackageManager.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>PackageManager</RootNamespace>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand All @@ -16,9 +16,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Costura.Fody" Version="3.1.6" />
<PackageReference Include="Neptuo" Version="6.0.0" />
<PackageReference Include="NuGet.PackageManagement" Version="4.8.0" />
<PackageReference Include="NuGet.PackageManagement" Version="5.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 12 additions & 5 deletions src/PackageManager.NuGet/Models/NuGetPackageSourceCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected override void DisposeManagedResources()
Provider.PackageSourcesChanged -= OnProviderChanged;
}

private void OnProviderChanged(object sender, EventArgs e)
private void OnProviderChanged(object sender, EventArgs e)
=> Changed?.Invoke();

private NuGetPackageSource EnsureType(IPackageSource source, string argumentName = null)
Expand All @@ -48,7 +48,7 @@ private NuGetPackageSource EnsureType(IPackageSource source, string argumentName
throw new InvalidPackageSourceImplementationException();
}

private PackageSource UnWrap(IPackageSource source, string argumentName = null)
private PackageSource UnWrap(IPackageSource source, string argumentName = null)
=> EnsureType(source, argumentName).Original;

public IPackageSourceBuilder Add()
Expand All @@ -75,8 +75,15 @@ public void MarkAsPrimary(IPackageSource source)
Provider.SaveActivePackageSource(UnWrap(source));
}

internal void SavePackageSources()
=> Provider.SavePackageSources(Sources.Select(s => s.Original));
internal void SavePackageSources(bool isOrderChanged = false)
{
// This is a workaround for change/bug in the underlaying package source provider,
// which ignores changed order. So we save an empty list and than the actual.
if (isOrderChanged)
Provider.SavePackageSources(Enumerable.Empty<PackageSource>());

Provider.SavePackageSources(Sources.Select(s => s.Original));
}

public int MoveUp(IPackageSource source)
{
Expand All @@ -86,7 +93,7 @@ public int MoveUp(IPackageSource source)
{
Sources.RemoveAt(index);
Sources.Insert(--index, target);
SavePackageSources();
SavePackageSources(true);
}

return index;
Expand Down
4 changes: 2 additions & 2 deletions src/PackageManager.NuGet/PackageManager.NuGet.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>PackageManager</RootNamespace>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neptuo" Version="6.0.0" />
<PackageReference Include="NuGet.PackageManagement" Version="4.8.0" />
<PackageReference Include="NuGet.PackageManagement" Version="5.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 0 additions & 6 deletions src/PackageManager.UI/App.config

This file was deleted.

4 changes: 0 additions & 4 deletions src/PackageManager.UI/FodyWeavers.xml

This file was deleted.

9 changes: 4 additions & 5 deletions src/PackageManager.UI/PackageManager.UI.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF>
<RootNamespace>PackageManager</RootNamespace>
<AssemblyName>PackageManager.UI</AssemblyName>
<TargetFramework>net461</TargetFramework>
<ApplicationIcon>Views\Assets\box-search-result.ico</ApplicationIcon>
<StartupObject>PackageManager.Program</StartupObject>
</PropertyGroup>
Expand All @@ -13,7 +15,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Costura.Fody" Version="3.1.6" />
<PackageReference Include="Neptuo.Exceptions" Version="1.2.1" />
<PackageReference Include="Neptuo.Observables" Version="2.0.0" />
</ItemGroup>
Expand Down Expand Up @@ -49,6 +50,4 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>

<Import Project="$(MSBuildProjectDirectory)\..\..\build\Wpf.Build.targets" />
</Project>
2 changes: 1 addition & 1 deletion src/PackageManager/PackageManager.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void Move()
var sources = CreateSourceCollection();
sources.Remove(sources.All.First());
var test1 = sources.Add().Name("Test1").Uri(new Uri("http://test1")).Save();
var test2 = sources.Add().Name("Test2").Uri(new Uri("http://test1")).Save();
var test2 = sources.Add().Name("Test2").Uri(new Uri("http://test2")).Save();

sources = CreateSourceCollection();
test1 = sources.All.First();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/PackageManager.Tests/PackageManager.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions tools/Prepare-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ If (!$isAppveyor)
}

dotnet restore ..\GitExtensions.PluginManager.sln

msbuild ..\GitExtensions.PluginManager.sln /p:Configuration=Release -verbosity:minimal
dotnet publish ..\src\PackageManager.UI\PackageManager.UI.csproj -c Release -p:PublishProfile=FolderProfile
dotnet publish ..\src\GitExtensions.PluginManager\GitExtensions.PluginManager.csproj --configuration Release -verbosity:minimal
if (!($LastExitCode -eq 0))
{
Pop-Location;
Write-Error -Message "MSBuild failed with $LastExitCode" -ErrorAction Stop
}

$packPath = Join-Path ".." $targetPath;
dotnet pack ..\src\GitExtensions.PluginManager -c Release -o $packPath --no-build
if (!(Test-Path $targetPath))
{
New-Item -ItemType Directory -Force -Path $targetPath
}

Copy-Item ..\src\GitExtensions.PluginManager\bin\Release\GitExtensions.PluginManager.*.zip $targetPath
Copy-Item ..\src\GitExtensions.PluginManager\bin\Release\GitExtensions.PluginManager.*.nupkg $targetPath
Expand Down
4 changes: 2 additions & 2 deletions tools/Zip-GitExtensionsPlugin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ $tempPmPath = Join-Path $tempPath -ChildPath "PackageManager";
New-Item -Force -ItemType Directory $tempPath | Out-Null;
New-Item -Force -ItemType Directory $tempPmPath | Out-Null;

Copy-Item -Force ($sourceBasePath + "\net461\GitExtensions.PluginManager.dll") $tempPath | Out-Null;
Copy-Item -Force ($sourceBasePath + "\net461\PackageManager\PackageManager.UI.exe") $tempPmPath | Out-Null;
Copy-Item -Force ($sourceBasePath + "\net5.0-windows\GitExtensions.PluginManager.dll") $tempPath | Out-Null;
Copy-Item -Force ($sourceBasePath + "\net5.0-windows\PackageManager\PackageManager.UI.exe") $tempPmPath | Out-Null;

Compress-Archive -Path ($tempPath + "\*") -DestinationPath $target -Force;
Write-Host ("Created release zip at '" + $target + "'");
Expand Down

0 comments on commit ab15af8

Please sign in to comment.