Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs
index 3ebdeb9..66c8236 100644
--- a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs
+++ b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs
@@ -134,6 +134,12 @@ public void Initalize(IConfiguration configuration)
compilationOptions = compilationOptions.WithAllowUnsafe(true);
}
+ if (projectFileInfo.SignAssembly && !string.IsNullOrEmpty(projectFileInfo.AssemblyOriginatorKeyFile))
+ {
+ compilationOptions = compilationOptions.WithStrongNameProvider(new DesktopStrongNameProvider())
+ .WithCryptoKeyFile(projectFileInfo.AssemblyOriginatorKeyFile);
+ }
+
var projectInfo = ProjectInfo.Create(ProjectId.CreateNewId(projectFileInfo.Name),
VersionStamp.Create(),
projectFileInfo.Name,
diff --git a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs
index 1d1f3a6..799161d 100644
--- a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs
+++ b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs
@@ -47,6 +47,10 @@ public class ProjectFileInfo
public OutputKind OutputKind { get; private set; }
+ public bool SignAssembly { get; private set; }
+
+ public string AssemblyOriginatorKeyFile { get; private set; }
+
public static ProjectFileInfo Create(MSBuildOptions options, ILogger logger, string solutionDirectory, string projectFilePath, ICollection<MSBuildDiagnosticsMessage> diagnostics)
{
var projectFileInfo = new ProjectFileInfo();
@@ -133,6 +137,14 @@ public static ProjectFileInfo Create(MSBuildOptions options, ILogger logger, str
{
projectFileInfo.DefineConstants = defineConstants.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();
}
+
+ var signAssembly = projectInstance.GetPropertyValue("SignAssembly");
+ if (!string.IsNullOrWhiteSpace(signAssembly))
+ {
+ projectFileInfo.SignAssembly = Convert.ToBoolean(signAssembly);
+ }
+
+ projectFileInfo.AssemblyOriginatorKeyFile = Path.Combine(projectFileInfo.ProjectDirectory, projectInstance.GetPropertyValue("AssemblyOriginatorKeyFile"));
}
else
{
@@ -211,6 +223,14 @@ public static ProjectFileInfo Create(MSBuildOptions options, ILogger logger, str
{
projectFileInfo.DefineConstants = defineConstants.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();
}
+
+ var signAssembly = properties["SignAssembly"].FinalValue;
+ if (!string.IsNullOrWhiteSpace(signAssembly))
+ {
+ projectFileInfo.SignAssembly = Convert.ToBoolean(signAssembly);
+ }
+
+ projectFileInfo.AssemblyOriginatorKeyFile = Path.Combine(projectFileInfo.ProjectDirectory, properties["AssemblyOriginatorKeyFile"].FinalValue);
}
return projectFileInfo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment