Skip to content

Commit

Permalink
Merge pull request #1613 from manio143/fix_script_editor
Browse files Browse the repository at this point in the history
Update NuGet dependencies to 6.4.0 (temporary fix for ScriptEditor issues)
  • Loading branch information
manio143 committed Feb 19, 2023
2 parents d0e9ff2 + 5947e9f commit 0635a32
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<StrideAssemblyProcessorOptions>--auto-module-initializer --serialization</StrideAssemblyProcessorOptions>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGet.Protocol" Version="6.0.0" />
<PackageReference Include="NuGet.PackageManagement" Version="6.0.0" />
<PackageReference Include="NuGet.Resolver" Version="6.0.0" />
<PackageReference Include="NuGet.Commands" Version="6.0.0" />
<PackageReference Include="NuGet.Protocol" Version="6.4.0" />
<PackageReference Include="NuGet.PackageManagement" Version="6.4.0" />
<PackageReference Include="NuGet.Resolver" Version="6.4.0" />
<PackageReference Include="NuGet.Commands" Version="6.4.0" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion sources/core/Stride.Core.Design/Stride.Core.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="2.3.2262-g94fae01e" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="6.0.0" />
<PackageReference Include="NuGet.Configuration" Version="6.0.0" />
<PackageReference Include="NuGet.Configuration" Version="6.4.0" />
<PackageReference Include="SharpDX" Version="4.2.0" />
<PackageReference Include="System.Management" Version="4.7.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Stride.Core.Extensions;
using Stride.Assets.Presentation.AssetEditors.ScriptEditor;
using Project = Microsoft.CodeAnalysis.Project;
using System.Diagnostics;

namespace Stride.Assets.Presentation.AssetEditors
{
Expand Down Expand Up @@ -354,8 +355,6 @@ private async Task<Project> OpenProject(UFile projectPath)
{
if (msbuildWorkspace == null)
{
// Only load workspace for C# assemblies (default includes VB but not added as a NuGet package)
//var csharpWorkspaceAssemblies = new[] { Assembly.Load("Microsoft.CodeAnalysis.Workspaces"), Assembly.Load("Microsoft.CodeAnalysis.CSharp.Workspaces"), Assembly.Load("Microsoft.CodeAnalysis.Workspaces.Desktop") };
var host = await RoslynHost;
msbuildWorkspace = MSBuildWorkspace.Create(ImmutableDictionary<string, string>.Empty, host.HostServices);
}
Expand All @@ -370,43 +369,13 @@ private async Task<Project> OpenProject(UFile projectPath)
{
var project = await msbuildWorkspace.OpenProjectAsync(projectPath.ToWindowsPath());

// Change the default CSharp language version to match the supported version for a specific visual studio version or MSBuild version
// this is because roslyn will always resolve Default to Latest which might not match the
// latest version supported by the build tools installed on the machine
var csharpParseOptions = project.ParseOptions as CSharpParseOptions;
if (csharpParseOptions != null)
if (msbuildWorkspace.Diagnostics.Count > 0)
{
if (csharpParseOptions.SpecifiedLanguageVersion == LanguageVersion.Default || csharpParseOptions.SpecifiedLanguageVersion == LanguageVersion.Latest)
{
LanguageVersion targetLanguageVersion = csharpParseOptions.SpecifiedLanguageVersion;

// Check the visual studio version inside the solution first, which is what visual studio uses to decide which version to open
// this should not be confused with the toolsVersion below, since this is the MSBuild version (they might be different)
Version visualStudioVersion = session.CurrentProject?.Package.Session.VisualStudioVersion;
if (visualStudioVersion != null)
{
if (visualStudioVersion.Major <= 14)
{
targetLanguageVersion = LanguageVersion.CSharp6;
}

}
else
{
// Fallback to checking the tools version on the csproj
// this happens when you open an sdpkg instead of a sln file as a project
ProjectRootElement xml = ProjectRootElement.Open(projectPath);
Version toolsVersion;
if (Version.TryParse(xml.ToolsVersion, out toolsVersion))
{
if (toolsVersion.Major <= 14)
{
targetLanguageVersion = LanguageVersion.CSharp6;
}
}
}
project = project.WithParseOptions(csharpParseOptions.WithLanguageVersion(targetLanguageVersion));
}
// There was an issue compiling the project
// at the moment there's no mechanism to surface those errors to the UI, so leaving this in here:
//if (Debugger.IsAttached) Debugger.Break();
foreach (var diagnostic in msbuildWorkspace.Diagnostics)
Debug.WriteLine(diagnostic.Message, category: nameof(ProjectWatcher));
}
return project;
}
Expand Down
8 changes: 4 additions & 4 deletions sources/tools/Stride.NuGetLoader/Stride.NuGetLoader.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
Expand All @@ -17,9 +17,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NuGet.PackageManagement" Version="6.0.0" />
<PackageReference Include="NuGet.Resolver" Version="6.0.0" />
<PackageReference Include="NuGet.Commands" Version="6.0.0" />
<PackageReference Include="NuGet.PackageManagement" Version="6.4.0" />
<PackageReference Include="NuGet.Resolver" Version="6.4.0" />
<PackageReference Include="NuGet.Commands" Version="6.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Build" Version="17.0.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.0.0" ExcludeAssets="runtime" />
<PackageReference Include="NuGet.Commands" Version="6.0.0" />
<PackageReference Include="NuGet.Commands" Version="6.4.0" />

<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Design" />
Expand Down

0 comments on commit 0635a32

Please sign in to comment.