Skip to content

Commit

Permalink
Feature/7 use msbuild api to load projects (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
matzefriedrich authored Jun 6, 2024
1 parent eee7534 commit 1189e16
Show file tree
Hide file tree
Showing 41 changed files with 920 additions and 166 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- [PR #8] The application can access package configuration properties directly from project files and override/tweak them as needed. The `add` and `restore` commands now support the `--configuration` flag, as known from other `dotnet` commands. (#7)
- Adds support for F# project files (#7)

### Changed

- [PR #8] Changes services involved with building and packing NuGet packages.
- [PR #8] The `dotnet pack` command is now invoked with the `-p:NuspecFile` option; Nuspec files are dynamically generated from project files (#7)


### Fixed

- [PR #8] Fixes broken task factories

## [0.2.0-alpha1.240419.1] - 2024-04-19

### Added
Expand Down
1 change: 0 additions & 1 deletion src/dotnet.nugit.Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

239 changes: 122 additions & 117 deletions src/dotnet.nugit.Resources/Resources.resx
Original file line number Diff line number Diff line change
@@ -1,126 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ArgumentException_Value_cannot_be_null_or_whitespace" xml:space="preserve">
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="ArgumentException_Value_cannot_be_null_or_whitespace" xml:space="preserve">
<value>Value cannot be null or whitespace.</value>
</data>
<data name="Program_Help_description" xml:space="preserve">
<data name="Program_Help_description" xml:space="preserve">
<value>Build NuGet packages from GitHub and integrate them seamlessly.</value>
</data>
</root>
18 changes: 9 additions & 9 deletions src/dotnet.nugit.Resources/dotnet.nugit.Resources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Update="Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

</Project>
19 changes: 15 additions & 4 deletions src/dotnet.nugit.UnitTest/FindAndBuildProjectsTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace dotnet.nugit.UnitTest
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Services.Tasks;
using Services.Workspace;

public class FindAndBuildProjectsTaskTest
{
Expand All @@ -32,11 +33,11 @@ public async Task FindAndBuildProjectsTask_Test()

var dotNetUtilityMock = new Mock<IDotNetUtility>();
dotNetUtilityMock
.Setup(utility => utility.BuildAsync(projectFilePath, It.IsAny<TimeSpan?>(), It.IsAny<CancellationToken>()))
.Setup(utility => utility.BuildAsync(It.IsAny<IDotNetProject>(), It.IsAny<TimeSpan?>(), It.IsAny<CancellationToken>()))
.Verifiable();

dotNetUtilityMock
.Setup(utility => utility.TryPackAsync(projectFilePath, It.IsAny<string>(), It.IsAny<PackOptions>(), It.IsAny<TimeSpan?>(), It.IsAny<CancellationToken>()))
.Setup(utility => utility.TryPackAsync(It.IsAny<IDotNetProject>(), It.IsAny<string>(), It.IsAny<PackOptions>(), It.IsAny<TimeSpan?>(), It.IsAny<CancellationToken>()))
.Verifiable();

var projectFilesList = new List<string> { projectFilePath };
Expand All @@ -47,9 +48,19 @@ public async Task FindAndBuildProjectsTask_Test()
.Returns(projectFilesList.ToAsyncEnumerable)
.Verifiable();

var projectAccessorMock = new Mock<IDotNetProject>();
projectAccessorMock.Setup(accessor => accessor.DerivePackageSpec()).Returns(ProjectPackageMetadata.Empty());

var projectWorkspaceManagerMock = new Mock<IProjectWorkspaceManager>();
projectWorkspaceManagerMock
.Setup(manager => manager.LoadProjectAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(projectAccessorMock.Object)
.Verifiable();

var sut = new FindAndBuildProjectsTask(
workspaceMock.Object,
dotNetUtilityMock.Object,
projectWorkspaceManagerMock.Object,
finderMock.Object,
fileSystem,
new NullLogger<FindAndBuildProjectsTask>());
Expand All @@ -59,8 +70,8 @@ public async Task FindAndBuildProjectsTask_Test()

// Assert
finderMock.Verify(service => service.FindAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Func<FileSystemEntry, Task<bool>>>(), It.IsAny<CancellationToken>()), Times.Once);
dotNetUtilityMock.Verify(utility => utility.BuildAsync(projectFilePath, It.IsAny<TimeSpan?>(), It.IsAny<CancellationToken>()), Times.Once);
dotNetUtilityMock.Verify(utility => utility.TryPackAsync(projectFilePath, It.IsAny<string>(), It.IsAny<PackOptions>(), It.IsAny<TimeSpan?>(), It.IsAny<CancellationToken>()), Times.Once);
dotNetUtilityMock.Verify(utility => utility.BuildAsync(It.IsAny<IDotNetProject>(), It.IsAny<TimeSpan?>(), It.IsAny<CancellationToken>()), Times.Once);
dotNetUtilityMock.Verify(utility => utility.TryPackAsync(It.IsAny<IDotNetProject>(), It.IsAny<string>(), It.IsAny<PackOptions>(), It.IsAny<TimeSpan?>(), It.IsAny<CancellationToken>()), Times.Once);
}
}
}
2 changes: 1 addition & 1 deletion src/dotnet.nugit.UnitTest/Mocking/MockCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public MockCommit(string sha)
{
this.Sha = sha;
}

public override string Sha { get; }
}
}
2 changes: 1 addition & 1 deletion src/dotnet.nugit.UnitTest/NugitWorkspaceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task NugitWorkspace_invokes_create_callback_if_workspace_file_not_f

var mockFileSystem = new MockFileSystem();
using var environment = new TemporaryDirectoryWorkspaceEnvironment(mockFileSystem);

var sut = new NugitWorkspace(environment, new NullLogger<NugitWorkspace>());

var createDelegateMock = new Mock<Func<NugitConfigurationFile>>();
Expand Down
3 changes: 3 additions & 0 deletions src/dotnet.nugit.UnitTest/RestorePackagesCommandTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ public async Task RestorePackagesCommand_RestoreWorkspacePackagesAsync_build_hea
.Setup(task => task.BuildRepositoryPackagesAsync(repositoryReference, feed, repositoryMock.Object, null, null, It.IsAny<CancellationToken>()))
.Verifiable();

var msBuildToolsLocatorMock = new Mock<IMsBuildToolsLocator>();

var sut = new RestorePackagesCommand(
workspaceMock.Object,
msBuildToolsLocatorMock.Object,
OpenRepositoryTaskFactory,
BuildPackagesTaskFactory,
new NullLogger<RestorePackagesCommand>());
Expand Down
Loading

0 comments on commit 1189e16

Please sign in to comment.