Skip to content

Commit

Permalink
Support for .NET 7 (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkl authored May 6, 2022
1 parent 1cec157 commit 9e6fee5
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 9 deletions.
7 changes: 7 additions & 0 deletions azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ variables:
DotNetCore3Version: '3.x'
DotNet5Version: '5.x'
DotNet6Version: '6.x'
DotNet7Version: '7.x'
MSBuildArgs: '"/p:Platform=$(BuildPlatform)" "/p:Configuration=$(BuildConfiguration)" "/BinaryLogger:$(Build.SourcesDirectory)\$(ArtifactsDirectoryName)\msbuild.binlog"'
SignType: 'Test'

Expand Down Expand Up @@ -58,6 +59,12 @@ stages:
inputs:
version: '$(DotNet6Version)'

- task: UseDotNet@2
displayName: 'Install .NET $(DotNet7Version)'
inputs:
version: '$(DotNet7Version)'
includePreviewVersions: true

- task: MicroBuildSigningPlugin@1
displayName: 'Install MicroBuild Signing Plugin'
inputs:
Expand Down
43 changes: 43 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ variables:
DotNetCore3Version: '3.x'
DotNet5Version: '5.x'
DotNet6Version: '6.x'
DotNet7Version: '7.x'
MSBuildArgs: '"/p:Platform=$(BuildPlatform)" "/p:Configuration=$(BuildConfiguration)" "/BinaryLogger:$(Build.SourcesDirectory)/$(ArtifactsDirectoryName)/msbuild.binlog"'
SignType: 'Test'
UnitTestProjectPath: 'src/Microsoft.VisualStudio.SlnGen.UnitTests/Microsoft.VisualStudio.SlnGen.UnitTests.csproj'
Expand Down Expand Up @@ -51,6 +52,12 @@ jobs:
inputs:
version: '$(DotNet6Version)'

- task: UseDotNet@2
displayName: 'Install .NET $(DotNet7Version)'
inputs:
version: '$(DotNet7Version)'
includePreviewVersions: true

- task: VSBuild@1
displayName: 'Build Solution'
inputs:
Expand Down Expand Up @@ -89,6 +96,14 @@ jobs:
testRunTitle: 'Windows .NET 6.0'
condition: succeededOrFailed()

- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests (.NET 7)'
inputs:
command: 'test'
arguments: '--no-restore --no-build --framework net7.0 /noautorsp /BinaryLogger:$(Build.SourcesDirectory)/$(ArtifactsDirectoryName)/test.net7.0.binlog'
testRunTitle: 'Windows .NET 7.0'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
Expand Down Expand Up @@ -116,6 +131,12 @@ jobs:
inputs:
version: '$(DotNet6Version)'

- task: UseDotNet@2
displayName: 'Install .NET $(DotNet7Version)'
inputs:
version: '$(DotNet7Version)'
includePreviewVersions: true

- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
Expand Down Expand Up @@ -150,6 +171,14 @@ jobs:
testRunTitle: 'Linux .NET 6.0'
condition: succeededOrFailed()

- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests (.NET 7)'
inputs:
command: 'test'
arguments: '--framework net7.0'
testRunTitle: 'Linux .NET 7.0'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
Expand All @@ -176,6 +205,12 @@ jobs:
displayName: 'Install .NET $(DotNet6Version)'
inputs:
version: '$(DotNet6Version)'

- task: UseDotNet@2
displayName: 'Install .NET $(DotNet7Version)'
inputs:
version: '$(DotNet7Version)'
includePreviewVersions: true

- task: DotNetCoreCLI@2
displayName: 'Build'
Expand Down Expand Up @@ -211,6 +246,14 @@ jobs:
testRunTitle: 'MacOS .NET 6.0'
condition: succeededOrFailed()

- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests (.NET 7)'
inputs:
command: 'test'
arguments: '--framework net7.0'
testRunTitle: 'MacOS .NET 7.0'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
Expand Down
5 changes: 3 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"sdk": {
"version": "6.0.100",
"rollForward": "latestMinor"
"version": "6.0.0",
"rollForward": "latestMajor",
"allowPrerelease": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\vssdk\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true"
TargetFramework="net6.0" />
<ProjectReference Include="..\Microsoft.VisualStudio.SlnGen\Microsoft.VisualStudio.SlnGen.csproj"
SetTargetFramework="TargetFramework=net7.0"
IncludeAssets="None"
OutputItemType="SlnGenBuildOutput"
PrivateAssets="All"
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true"
TargetFramework="net7.0" />
</ItemGroup>
<Target Name="CopySlnGenToOutputDirectoryAndPackage"
AfterTargets="PrepareForRun"
Expand Down
6 changes: 5 additions & 1 deletion src/Microsoft.VisualStudio.SlnGen.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ public static int Main(string[] args)
framework = "net6.0";
break;

case "7":
framework = "net7.0";
break;

default:
Console.WriteLine($"The .NET SDK {developmentEnvironment.DotNetSdkVersion} is not supported");
Console.WriteLine($"SlnGen does not currently support the .NET SDK {developmentEnvironment.DotNetSdkVersion} defined by in global.json. Please update to the latest version and if you still get this error message, file an issue at https://github.com/microsoft/slngen/issues/new so it can be added.");

return -1;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);SA1600</NoWarn>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;net472;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net461;net472;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.config</AllowedOutputExtensionsInPackageBuildOutputFolder>
<IncludeReferenceCopyLocalPathsInBuildOutputInPackage>true</IncludeReferenceCopyLocalPathsInBuildOutputInPackage>
<IsTool>true</IsTool>
Expand Down Expand Up @@ -30,7 +30,7 @@
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net472\MSBuild.exe" Private="false" Condition="'$(TargetFramework)' == 'net472'" />
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\netcoreapp2.1\MSBuild.dll" Private="false" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net5.0\MSBuild.dll" Private="false" Condition="'$(TargetFramework)' == 'net5.0'" />
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net6.0\MSBuild.dll" Private="false" Condition="'$(TargetFramework)' == 'net6.0'" />
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net6.0\MSBuild.dll" Private="false" Condition="'$(TargetFramework)' == 'net6.0' Or '$(TargetFramework)' == 'net7.0'" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net472'" />
Expand Down
6 changes: 5 additions & 1 deletion src/Microsoft.VisualStudio.SlnGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ public static int Main(string[] args)

AssemblyName candidateAssemblyName = AssemblyName.GetAssemblyName(candidateAssemblyFileInfo.FullName);

#if !NET7_0_OR_GREATER
if ((requestedAssemblyName.ProcessorArchitecture != ProcessorArchitecture.None && requestedAssemblyName.ProcessorArchitecture != candidateAssemblyName.ProcessorArchitecture)
|| (requestedAssemblyName.Flags.HasFlag(AssemblyNameFlags.PublicKey) && !requestedAssemblyName.GetPublicKeyToken() !.SequenceEqual(candidateAssemblyName.GetPublicKeyToken() !)))
|| (requestedAssemblyName.Flags.HasFlag(AssemblyNameFlags.PublicKey) && !requestedAssemblyName.GetPublicKeyToken() !.SequenceEqual(candidateAssemblyName.GetPublicKeyToken()) !))
#else
if (requestedAssemblyName.Flags.HasFlag(AssemblyNameFlags.PublicKey) && !requestedAssemblyName.GetPublicKeyToken() !.SequenceEqual(candidateAssemblyName.GetPublicKeyToken() !))
#endif
{
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Shared/DevelopmentEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,14 @@ private static FileInfo GetPathToMSBuildExe(FileInfo msbuildExeFileInfo)
throw new ArgumentNullException(nameof(msbuildExeFileInfo));
}

#if NETFRAMEWORK
AssemblyName assemblyName = AssemblyName.GetAssemblyName(msbuildExeFileInfo.FullName);

if (RuntimeInformation.ProcessArchitecture == Architecture.X64 && assemblyName.ProcessorArchitecture != ProcessorArchitecture.Amd64)
{
return new FileInfo(Path.Combine(msbuildExeFileInfo.DirectoryName!, "amd64", msbuildExeFileInfo.Name));
}
#endif

return msbuildExeFileInfo;
}
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "8.4",
"version": "8.5",
"assemblyVersion": "3.0",
"buildNumberOffset": -1,
"publicReleaseRefSpec": [
Expand Down

0 comments on commit 9e6fee5

Please sign in to comment.