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

SlnGen unexpectedly fails when using dotnet restore #571

Open
Aegle1 opened this issue Jan 17, 2024 · 0 comments
Open

SlnGen unexpectedly fails when using dotnet restore #571

Aegle1 opened this issue Jan 17, 2024 · 0 comments
Labels
bug Something isn't working help wanted Looking for community contributions!

Comments

@Aegle1
Copy link

Aegle1 commented Jan 17, 2024

SlnGen succeeds when using msbuild but fails when using dotnet restore.

msbuild /restore /t:SlnGen dirs.proj // successful
dotnet restore /t:SlnGen dirs.proj // fail

Reproduce setup:
OS: Windows 11 23H2 Build 22631.3007
Visual Studio version: VS Community 2022 17.8.3

File structure:

-
|-dirs.proj
|-global.json
|-directory.build.props
|-directory.packages.props
|-src
    |-dirs.proj
    |-ConsoleApp
        |-ConsoleApp.csproj
        |-Program.cs

File content:
dirs.proj

<Project Sdk="Microsoft.Build.Traversal">
    <ItemGroup>
        <ProjectReference Include="src\dirs.proj" />
    </ItemGroup>
</Project>

global.json

{
    "msbuild-sdks": {
        "Microsoft.Build.Traversal": "4.1.0"
    }
}

directory.build.props

<Project>
    <PropertyGroup>
        <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
        <SlnGenSolutionFileFullPath>$(MSBuildProjectDirectory)\dirs.sln</SlnGenSolutionFileFullPath>
        <SlnGenLaunchVisualStudio>false</SlnGenLaunchVisualStudio>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.VisualStudio.SlnGen" />
    </ItemGroup>
</Project>

directory.packages.props

<Project>
    <ItemGroup>
        <PackageVersion Include="Microsoft.VisualStudio.SlnGen" version="11.1.0" />
    </ItemGroup>
</Project>

src/dirs.proj

<Project Sdk="Microsoft.Build.Traversal">
    <ItemGroup>
        <ProjectReference Include="ConsoleApp\ConsoleApp.csproj" />
    </ItemGroup>
</Project>

src/ConsoleApp/ConsoleApp.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
</Project>

src/ConsoleApp/Program.cs

Console.WriteLine("Hello, World!");

Output:

C:\Workspace\SlnGenRepro>msbuild /Restore /t:SlnGen dirs.proj
MSBuild version 17.8.3+195e7f5a3 for .NET Framework
Build started 1/17/2024 2:57:47 AM

......

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:05.94

C:\Workspace\SlnGenRepro>dotnet restore /t:SlnGen
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Users\<user-name>\.nuget\packages\microsoft.visualstudio.slngen\11.1.0\build\Microsoft.VisualStudio.SlnGen.targets(30,5):
error MSB6006: "slngen" exited with code -2147450730. [C:\Workspace\SlnGenRepro\dirs.proj]

C:\Workspace\SlnGenRepro>
@mruxmohan4 mruxmohan4 added bug Something isn't working help wanted Looking for community contributions! labels Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Looking for community contributions!
Projects
None yet
Development

No branches or pull requests

2 participants