Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkl committed Nov 8, 2022
1 parent a5d4851 commit 10df9ec
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 10 deletions.
1 change: 1 addition & 0 deletions test/EndToEnd/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Project />
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<TestProjectType>functional</TestProjectType>
<Description>Functional tests for nuget in dotnet CLI scenarios, using the NuGet.CommandLine.XPlat assembly.</Description>
<UseParallelXunit>true</UseParallelXunit>
<NoWarn>$(NoWarn);NU1701</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Runtime" />
<PackageReference Include="Microsoft.CodeAnalysis.Build.Tasks" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" IncludeAssets="None" PrivateAssets="All" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>

Expand All @@ -28,11 +29,8 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="Microsoft.Net.Compilers.netcore" />
</ItemGroup>
<Target Name="CopyTargets" AfterTargets="AfterBuild">
<Copy Condition=" '$(IsCore)' == 'true' " SourceFiles="$(MSBuildProjectDirectory)\$(OutputPath)\Microsoft.CSharp.Core.targets" DestinationFolder="$(MSBuildProjectDirectory)\$(OutputPath)\Roslyn\" />
<Copy Condition="'$(TargetFramework)' == '$(NETFXTargetFramework)'" SourceFiles="$(MSBuildProjectDirectory)\$(OutputPath)\Microsoft.CSharp.Core.targets" DestinationFolder="$(MSBuildProjectDirectory)\$(OutputPath)\..\..\Bin\Roslyn\" />
<Copy Condition=" '$(IsCore)' == 'true' " SourceFiles="$(PkgMicrosoft_Net_Compilers_Toolset)\tasks\netcoreapp3.1\Microsoft.Managed.Core.targets;$(PkgMicrosoft_Net_Compilers_Toolset)\tasks\netcoreapp3.1\Microsoft.CSharp.Core.targets" DestinationFolder="$(MSBuildProjectDirectory)\$(OutputPath)\Roslyn\" />
<Copy Condition="'$(TargetFramework)' == '$(NETFXTargetFramework)'" SourceFiles="$(PkgMicrosoft_Net_Compilers_Toolset)\tasks\net472\Microsoft.Managed.Core.targets;$(PkgMicrosoft_Net_Compilers_Toolset)\tasks\net472\Microsoft.CSharp.Core.targets" DestinationFolder="$(MSBuildProjectDirectory)\$(OutputPath)\..\..\Bin\Roslyn\" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<NoWarn>$(NoWarn);NU1505</NoWarn> <!-- Remove NoWarn when https://github.com/dotnet/sdk/issues/24747 is fixed -->
<Description>A utility for updating the NuGet license list from the SPDX source.</Description>
<!-- There are some conflicts that are impossible to resolve because of missing package versions-->
<MicrosoftCodeAnalysisCSharpVersion>3.0.0</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisVersion>3.0.0</MicrosoftCodeAnalysisVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Microsoft.CodeAnalysis" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.CodeAnalysis" VersionOverride="$(MicrosoftCodeAnalysisVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" VersionOverride="$(MicrosoftCodeAnalysisVersion)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.ProjectSystem.Interop;

namespace Test.Utility.ProjectManagement
{
Expand Down Expand Up @@ -69,4 +69,124 @@ public Task UninstallPackageAsync(INuGetPackageMoniker package, IReadOnlyDiction
return Task.Run(() => { _installedPackages.RemoveAll(p => p.Id == package.Id && p.Version == package.Version); });
}
}

/// <summary>
/// Represents metadata about a nuget package.
/// </summary>
[ComImport]
[Guid("BCA2E197-E352-4474-B0A7-D8CE606CD4E9")]
public interface INuGetPackageMoniker
{
/// <summary>
/// Gets the Id of package.
/// </summary>
string Id { get; }

/// <summary>
/// Gets the Version of package.
/// </summary>
string Version { get; }
}

/// <summary>
/// Represents the progress of a nuget installation operation.
/// </summary>
[ComImport]
[Guid("93B269C4-85D6-4AEA-9398-81754CA2560B")]
public interface INuGetPackageInstallProgress
{
/// <summary>
/// Count of packages installed so far.
/// </summary>
int InstalledPackagesCount { get; }

/// <summary>
/// Count of packages to be installed.
/// </summary>
int TotalPackagesToInstall { get; }
}

[ComImport]
[Guid("FD2DC07E-9054-4115-B86B-26A9F9C1F00B")]
public interface INuGetPackageManager
{
/// <summary>
/// Returns the list of packages installed in the project. This should
/// return only the direct dependencies.
/// </summary>
/// <remarks>
/// A class with generic parameters (Task in this case)
/// cannot use embedded types as type parameters.
/// (See: http://msdn.microsoft.com/en-us/library/dd264728.aspx).
/// That's the reason why the return type is marked as collection of objects rather than
/// <see cref="T:Microsoft.VisualStudio.ProjectSystem.Interop.INuGetPackageMoniker" /> because the latter is an embedded type.
/// The actual implementations should return <see cref="T:Microsoft.VisualStudio.ProjectSystem.Interop.INuGetPackageMoniker" /> objects
/// in the collection.
/// </remarks>
Task<IReadOnlyCollection<object>> GetInstalledPackagesAsync(CancellationToken cancellationToken);

/// <summary>
/// Installs a package in the project.
/// </summary>
/// <param name="package">Package to install.</param>
/// <param name="options">Any options specified by the user.</param>
/// <param name="logger">Logger to report the progress back to the NuGet. Can be null.</param>
/// <param name="progress">To report the progress back to NuGet. Can be null.</param>
/// <param name="cancellationToken">Cancellation token.Cancellation token. When responding
/// to cancellation, the implementors should ensure the rollback of
/// everything done and bring the project to original state.</param>
/// <remarks>
/// This should typically download the package and it's dependencies into the
/// project's packages folder, modify the package manifest file for the project,
/// add references to assemblies and any other additional steps
/// required for the package installation.
/// </remarks>
Task InstallPackageAsync(INuGetPackageMoniker package, IReadOnlyDictionary<string, object> options, TextWriter logger, IProgress<INuGetPackageInstallProgress> progress, CancellationToken cancellationToken);

/// <summary>
/// Uninstalls the package.
/// </summary>
/// <param name="package">Package to uninstall.</param>
/// <param name="options">Any options specified by the user.</param>
/// <param name="logger">Logger to report the progress back to the NuGet.</param>
/// <param name="progress">To report the progress back to NuGet.</param>
/// <param name="cancellationToken">Cancellation token. When responding
/// to cancellation, the implementors should ensure the rollback of
/// everything done and bring the project to original state.</param>
/// <remarks>
/// This should handle all the steps required to remove the project's dependency
/// on package like removing the package reference from package manifest and also
/// removing assembly references and any other additional steps.
/// </remarks>
Task UninstallPackageAsync(INuGetPackageMoniker package, IReadOnlyDictionary<string, object> options, TextWriter logger, IProgress<INuGetPackageInstallProgress> progress, CancellationToken cancellationToken);

/// <summary>
/// Specifies whether the current implementation actually supports the given option.
/// </summary>
/// <param name="optionName">Option name.</param>
/// <param name="operation">NuGet Operation.</param>
/// <returns><see langword="true" /> if the given optionName is supported for the given operation by
/// this implementation; otherwise, <see langword="false" />.</returns>
bool CanSupport(string optionName, NuGetOperation operation);

/// <summary>
/// Gets a list of frameworks supported by the project system.
/// </summary>
/// <returns>A readonly collection of <see cref="T:System.Runtime.Versioning.FrameworkName" />s
/// supported by the project system.</returns>
Task<IReadOnlyCollection<FrameworkName>> GetSupportedFrameworksAsync(CancellationToken cancellationToken);
}

public enum NuGetOperation
{
/// <summary>
/// Represent installing a package.
/// </summary>
Install,
/// <summary>
/// Represents uninstalling a package.
/// </summary>
Uninstall
}

}
3 changes: 3 additions & 0 deletions test/TestUtilities/Test.Utility/Test.Utility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Tasks.Core" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Sdk" />
</ItemGroup>
Expand Down

0 comments on commit 10df9ec

Please sign in to comment.