Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: implicitly run dotnet restore #8419

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
dotnet-version: |
6.x
7.0.102
7.x

- run: npm install
working-directory: templates
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
dotnet-version: |
6.x
7.0.102
7.x
- run: npm install
working-directory: templates
Expand Down
8 changes: 8 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
</packageSources>
</configuration>
107 changes: 0 additions & 107 deletions docfx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DocAsCode.Dotnet.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DocAsCode.Dotnet", "src\Microsoft.DocAsCode.Dotnet\Microsoft.DocAsCode.Dotnet.csproj", "{B4EFC288-DC3B-4700-8F76-3F286FA80395}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{560F9BFD-38C6-4966-A3EA-B546B28016DC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildFromAssembly", "samples\seed\dotnet\assembly\BuildFromAssembly.csproj", "{55D62927-01F0-446B-B1E9-CF9142608FD0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildFromProject", "samples\seed\dotnet\project\Project\BuildFromProject.csproj", "{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CatLibrary", "samples\seed\dotnet\solution\CatLibrary\CatLibrary.csproj", "{81ECD832-9665-4258-9FC4-345E6EE204B6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CatLibrary.Core", "samples\seed\dotnet\solution\CatLibrary.Core\CatLibrary.Core.csproj", "{14BB2EC4-B97C-463E-A453-605FC8A3D53D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharp", "samples\csharp\src\CSharp.csproj", "{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "samples\extensions\build\build.csproj", "{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildFromProject.Core", "samples\seed\dotnet\project\Project.Core\BuildFromProject.Core.csproj", "{0709E02D-4E58-4F89-86B2-C95D1634485C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -766,90 +750,6 @@ Global
{B4EFC288-DC3B-4700-8F76-3F286FA80395}.Release|x64.Build.0 = Release|Any CPU
{B4EFC288-DC3B-4700-8F76-3F286FA80395}.Release|x86.ActiveCfg = Release|Any CPU
{B4EFC288-DC3B-4700-8F76-3F286FA80395}.Release|x86.Build.0 = Release|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Debug|x64.ActiveCfg = Debug|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Debug|x64.Build.0 = Debug|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Debug|x86.ActiveCfg = Debug|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Debug|x86.Build.0 = Debug|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Release|Any CPU.Build.0 = Release|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Release|x64.ActiveCfg = Release|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Release|x64.Build.0 = Release|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Release|x86.ActiveCfg = Release|Any CPU
{55D62927-01F0-446B-B1E9-CF9142608FD0}.Release|x86.Build.0 = Release|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Debug|x64.ActiveCfg = Debug|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Debug|x64.Build.0 = Debug|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Debug|x86.ActiveCfg = Debug|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Debug|x86.Build.0 = Debug|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Release|Any CPU.Build.0 = Release|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Release|x64.ActiveCfg = Release|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Release|x64.Build.0 = Release|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Release|x86.ActiveCfg = Release|Any CPU
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9}.Release|x86.Build.0 = Release|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Debug|x64.ActiveCfg = Debug|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Debug|x64.Build.0 = Debug|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Debug|x86.ActiveCfg = Debug|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Debug|x86.Build.0 = Debug|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Release|Any CPU.Build.0 = Release|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Release|x64.ActiveCfg = Release|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Release|x64.Build.0 = Release|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Release|x86.ActiveCfg = Release|Any CPU
{81ECD832-9665-4258-9FC4-345E6EE204B6}.Release|x86.Build.0 = Release|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Debug|x64.ActiveCfg = Debug|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Debug|x64.Build.0 = Debug|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Debug|x86.ActiveCfg = Debug|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Debug|x86.Build.0 = Debug|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Release|Any CPU.Build.0 = Release|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Release|x64.ActiveCfg = Release|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Release|x64.Build.0 = Release|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Release|x86.ActiveCfg = Release|Any CPU
{14BB2EC4-B97C-463E-A453-605FC8A3D53D}.Release|x86.Build.0 = Release|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Debug|x64.ActiveCfg = Debug|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Debug|x64.Build.0 = Debug|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Debug|x86.ActiveCfg = Debug|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Debug|x86.Build.0 = Debug|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Release|Any CPU.Build.0 = Release|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Release|x64.ActiveCfg = Release|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Release|x64.Build.0 = Release|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Release|x86.ActiveCfg = Release|Any CPU
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3}.Release|x86.Build.0 = Release|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Debug|Any CPU.Build.0 = Debug|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Debug|x64.ActiveCfg = Debug|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Debug|x64.Build.0 = Debug|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Debug|x86.ActiveCfg = Debug|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Debug|x86.Build.0 = Debug|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Release|Any CPU.ActiveCfg = Release|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Release|Any CPU.Build.0 = Release|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Release|x64.ActiveCfg = Release|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Release|x64.Build.0 = Release|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Release|x86.ActiveCfg = Release|Any CPU
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011}.Release|x86.Build.0 = Release|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Debug|x64.ActiveCfg = Debug|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Debug|x64.Build.0 = Debug|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Debug|x86.ActiveCfg = Debug|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Debug|x86.Build.0 = Debug|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Release|Any CPU.Build.0 = Release|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Release|x64.ActiveCfg = Release|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Release|x64.Build.0 = Release|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Release|x86.ActiveCfg = Release|Any CPU
{0709E02D-4E58-4F89-86B2-C95D1634485C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -910,13 +810,6 @@ Global
{3AC4C0C1-AC55-4E2D-8FF6-CE04A90B00B7} = {926A0726-B806-4215-82EF-AF8E22D0FACF}
{D6D2FA50-BFFA-4EAD-919B-5B58E8AE4DEB} = {926A0726-B806-4215-82EF-AF8E22D0FACF}
{B4EFC288-DC3B-4700-8F76-3F286FA80395} = {6A65A769-DAC3-4E99-96F9-991F4CE8D164}
{55D62927-01F0-446B-B1E9-CF9142608FD0} = {560F9BFD-38C6-4966-A3EA-B546B28016DC}
{310C66C8-C260-4AA2-828F-91B5D8E0F2C9} = {560F9BFD-38C6-4966-A3EA-B546B28016DC}
{81ECD832-9665-4258-9FC4-345E6EE204B6} = {560F9BFD-38C6-4966-A3EA-B546B28016DC}
{14BB2EC4-B97C-463E-A453-605FC8A3D53D} = {560F9BFD-38C6-4966-A3EA-B546B28016DC}
{7ADA6004-1B04-46CB-AB9E-F97A43F76BA3} = {560F9BFD-38C6-4966-A3EA-B546B28016DC}
{994CE5E6-9DB2-4BC2-97B3-7786D2E03011} = {560F9BFD-38C6-4966-A3EA-B546B28016DC}
{0709E02D-4E58-4F89-86B2-C95D1634485C} = {560F9BFD-38C6-4966-A3EA-B546B28016DC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6C12271F-8093-4D5D-8BEE-3318BFE40E23}
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.DocAsCode.Dotnet/DotnetApiCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private static ExtractMetadataConfig ConvertConfig(MetadataJsonItemConfig config
OutputFolder = Path.GetFullPath(Path.Combine(outputDirectory, outputFolder)),
CodeSourceBasePath = configModel?.CodeSourceBasePath,
DisableDefaultFilter = configModel?.DisableDefaultFilter ?? false,
NoRestore = configModel?.NoRestore ?? false,
NamespaceLayout = configModel?.NamespaceLayout ?? NamespaceLayout.Flattened,
Files = expandedFiles.Items.SelectMany(s => s.Files).ToList(),
References = expandedReferences?.Items.SelectMany(s => s.Files).ToList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ internal class ExtractMetadataConfig

public bool DisableDefaultFilter { get; init; }

public bool NoRestore { get; init; }

public NamespaceLayout NamespaceLayout { get; init; }

public Dictionary<string, string> MSBuildProperties { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Microsoft.DocAsCode.Dotnet
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -200,6 +201,10 @@ private async Task<Compilation> LoadCompilationFromProject(string path)
if (project is null)
{
Logger.LogInfo($"Loading project {path}");
if (!_config.NoRestore)
{
await Process.Start("dotnet", $"restore \"{path}\"").WaitForExitAsync();
}
project = await _workspace.OpenProjectAsync(path, _msbuildLogger);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.DocAsCode.Dotnet/MetadataJsonItemConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ internal class MetadataJsonItemConfig
[JsonProperty("disableDefaultFilter")]
public bool DisableDefaultFilter { get; set; }

[JsonProperty("noRestore")]
public bool NoRestore { get; set; }

[JsonProperty("namespaceLayout")]
public NamespaceLayout NamespaceLayout{ get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,5 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.4.0" />
<PackageReference Include="NuGet.ProjectModel" Version="6.4.0" />
<PackageReference Include="NuGet.Packaging.Core" Version="6.4.0" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<!--
The NuGet.Frameworks package is required to run csproj based tests targeting .NET 7.0.200.
Microsoft.NET.Test.Sdk bundles an old NuGet.Frameworks package to the output folder,
which takes predence over the one shipped with .NET SDK.
.NET 7.0.200 SDK depends on a newer NuGet.Frameworks package this is not availble on NuGet.org yet.
This only impact test since MSBuildLocator will resolve NuGet.Frameworks package from the appropreciate .NET SDK location.
-->
<PackageReference Include="NuGet.Frameworks" Version="6.5.0-*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageReference Include="xunit" Version="2.4.2" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions test/docfx.Snapshot.Tests/SamplesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public Task Seed()
var samplePath = $"{SamplesDir}/seed";
Clean(samplePath);

Process.Start("dotnet", $"build \"{samplePath}/dotnet/assembly/BuildFromAssembly.csproj\"").WaitForExit();

if (Debugger.IsAttached)
{
Environment.SetEnvironmentVariable("DOCFX_SOURCE_BRANCH_NAME", "main");
Expand Down
3 changes: 0 additions & 3 deletions test/docfx.Tests/Assets/ref.csproj.sample.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="test.cs" />
</ItemGroup>
</Project>
3 changes: 0 additions & 3 deletions test/docfx.Tests/Assets/test.csproj.sample.1
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
<TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="test.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="ref.csproj">
<Name>ClassLibrary1</Name>
Expand Down