Skip to content

Commit

Permalink
Use probing paths when signing as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
brutaldev committed Jan 7, 2016
1 parent 89805b6 commit 7368aa0
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If you are making use of the [NuGet package](https://www.nuget.org/packages/Brut
```xml
<Target Name="BeforeBuild">
<Exec ContinueOnError="false"
Command="&quot;..\packages\Brutal.Dev.StrongNameSigner.1.5.1\tools\StrongNameSigner.Console.exe&quot; -in &quot;..\packages&quot;" />
Command="&quot;..\packages\Brutal.Dev.StrongNameSigner.1.6.1\tools\StrongNameSigner.Console.exe&quot; -in &quot;..\packages&quot;" />
</Target>
```

Expand All @@ -46,7 +46,7 @@ To add multiple directories to process at the same time (similar to how the UI c
```xml
<Target Name="BeforeBuild">
<Exec ContinueOnError="false"
Command="&quot;..\packages\Brutal.Dev.StrongNameSigner.1.5.1\tools\StrongNameSigner.Console.exe&quot; -in &quot;..\packages\elmah.corelibrary.1.2.2|..\packages\Elmah.MVC.2.1.1&quot;" />
Command="&quot;..\packages\Brutal.Dev.StrongNameSigner.1.6.1\tools\StrongNameSigner.Console.exe&quot; -in &quot;..\packages\elmah.corelibrary.1.2.2|..\packages\Elmah.MVC.2.1.1&quot;" />
</Target>
```

Expand Down Expand Up @@ -75,7 +75,7 @@ For example, ServiceStack's PostgreSQL NuGet package is not signed but other dep
```xml
<Target Name="BeforeBuild">
<Exec ContinueOnError="false"
Command="&quot;..\packages\Brutal.Dev.StrongNameSigner.1.5.1\tools\StrongNameSigner.Console.exe&quot; -in &quot;..\packages\ServiceStack.OrmLite.PostgreSQL.4.0.40\lib\net40|..\packages\ServiceStack.Text.Signed.4.0.40\lib\net40|..\packages\ServiceStack.OrmLite.Signed.4.0.40&quot;" />
Command="&quot;..\packages\Brutal.Dev.StrongNameSigner.1.6.1\tools\StrongNameSigner.Console.exe&quot; -in &quot;..\packages\ServiceStack.OrmLite.PostgreSQL.4.0.40\lib\net40|..\packages\ServiceStack.Text.Signed.4.0.40\lib\net40|..\packages\ServiceStack.OrmLite.Signed.4.0.40&quot;" />
</Target>
```

Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# required metadata
sonar.projectKey=Brutal:Dev:StrongNameSigner
sonar.projectVersion=1.5.1
sonar.projectVersion=1.6.1
sonar.projectName=Strong Name Signer

# optional description
Expand Down
11 changes: 6 additions & 5 deletions src/Brutal.Dev.StrongNameSigner.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ private static Stats SignAssemblies(Options options)

var processedAssemblyPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var signedAssemblyPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var probingPaths = filesToSign.Select(f => Path.GetDirectoryName(f)).Distinct().ToArray();

foreach (var filePath in filesToSign)
{
var signedAssembly = SignSingleAssembly(filePath, options.KeyFile, options.OutputDirectory, options.Password);
var signedAssembly = SignSingleAssembly(filePath, options.KeyFile, options.OutputDirectory, options.Password, probingPaths);
if (signedAssembly != null)
{
processedAssemblyPaths.Add(signedAssembly.FilePath);
Expand All @@ -147,7 +148,7 @@ private static Stats SignAssemblies(Options options)
// Go through all the references excluding the file we are working on.
foreach (var referencePath in referencesToFix.Where(r => !r.Equals(filePath)))
{
if (FixSingleAssemblyReference(filePath, referencePath, options.KeyFile, options.Password, filesToSign.Select(f => Path.GetDirectoryName(f)).Distinct().ToArray()))
if (FixSingleAssemblyReference(filePath, referencePath, options.KeyFile, options.Password, probingPaths))
{
referenceFixes++;
}
Expand All @@ -157,7 +158,7 @@ private static Stats SignAssemblies(Options options)
// Remove all InternalsVisibleTo attributes without public keys from the processed assemblies. Signed assemblies cannot have unsigned friend assemblies.
foreach (var filePath in signedAssemblyPaths)
{
if (RemoveInvalidFriendAssemblyReferences(filePath, options.KeyFile, options.Password, filesToSign.Select(f => Path.GetDirectoryName(f)).Distinct().ToArray()))
if (RemoveInvalidFriendAssemblyReferences(filePath, options.KeyFile, options.Password, probingPaths))
{
referenceFixes++;
}
Expand All @@ -170,7 +171,7 @@ private static Stats SignAssemblies(Options options)
};
}

private static AssemblyInfo SignSingleAssembly(string assemblyPath, string keyPath, string outputDirectory, string password)
private static AssemblyInfo SignSingleAssembly(string assemblyPath, string keyPath, string outputDirectory, string password, params string[] probingPaths)
{
try
{
Expand All @@ -180,7 +181,7 @@ private static AssemblyInfo SignSingleAssembly(string assemblyPath, string keyPa
var info = SigningHelper.GetAssemblyInfo(assemblyPath);
if (!info.IsSigned)
{
info = SigningHelper.SignAssembly(assemblyPath, keyPath, outputDirectory, password);
info = SigningHelper.SignAssembly(assemblyPath, keyPath, outputDirectory, password, probingPaths);

PrintMessageColor(string.Format("'{0}' was strong-name signed successfully.", info.FilePath), LogLevel.Changes, ConsoleColor.Green);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.1.0")]
[assembly: AssemblyFileVersion("1.5.1.0")]
[assembly: AssemblyVersion("1.6.1.0")]
[assembly: AssemblyFileVersion("1.6.1.0")]
2 changes: 1 addition & 1 deletion src/Brutal.Dev.StrongNameSigner.Setup/EULA.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2015 Werner van Deventer ([email protected])
Copyright (c) 2013-2016 Werner van Deventer ([email protected])
All rights reserved.

* Redistribution of source code is strictly prohibited by means of reverse engineering or otherwise.
Expand Down
2 changes: 1 addition & 1 deletion src/Brutal.Dev.StrongNameSigner.Setup/StrongNameSigner.iss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define MyAppID "{A89C23E7-A764-4F59-8EF3-5AB0A33E5849}"
#define MyAppName ".NET Assembly Strong-Name Signer"
#define MyAppNameNoSpaces "StrongNameSigner"
#define MyAppVersion "1.5.1.0"
#define MyAppVersion "1.6.1.0"
#define MyAppPublisher "BrutalDev"
#define MyAppURL "https://github.com/brutaldev/StrongNameSigner"
#define MyAppExeName "StrongNameSigner.exe"
Expand Down
4 changes: 2 additions & 2 deletions src/Brutal.Dev.StrongNameSigner.Setup/StrongNameSigner.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Brutal.Dev.StrongNameSigner</id>
<version>1.5.1</version>
<version>1.6.1</version>
<title>.NET Assembly Strong-Name Signer</title>
<authors>Werner van Deventer</authors>
<owners>Werner van Deventer</owners>
Expand All @@ -19,7 +19,7 @@ The tool will also re-write the assembly references (as well as any InternalsVis
<releaseNotes>Cache generated strong-name keys to ensure all assemblies are signed with the same key pair. This ensure they are not invalidated when references are fixed and they get re-signed.</releaseNotes>
<copyright>Werner van Deventer (https://brutaldev.com)</copyright>
<language>en-US</language>
<tags>strongname assembly gac unsigned</tags>
<tags>strongname assembly gac unsigned strong name</tags>
</metadata>
<files>
<file src="..\Brutal.Dev.StrongNameSigner\bin\Release\Brutal.Dev.StrongNameSigner.dll" target="tools\Brutal.Dev.StrongNameSigner.dll" />
Expand Down
2 changes: 1 addition & 1 deletion src/Brutal.Dev.StrongNameSigner.UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ private void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
assemblyPair.OldInfo = SigningHelper.GetAssemblyInfo(filePath);
if (!assemblyPair.OldInfo.IsSigned)
{
assemblyPair.NewInfo = SigningHelper.SignAssembly(filePath, keyFile, outputPath, password);
assemblyPair.NewInfo = SigningHelper.SignAssembly(filePath, keyFile, outputPath, password, assemblyPaths.Select(f => Path.GetDirectoryName(f)).Distinct().ToArray());
log.Append("Strong-name signed successfully.").AppendLine();
signedAssemblyPaths.Add(filePath);
signedFiles++;
Expand Down
4 changes: 2 additions & 2 deletions src/Brutal.Dev.StrongNameSigner.UI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.1.0")]
[assembly: AssemblyFileVersion("1.5.1.0")]
[assembly: AssemblyVersion("1.6.1.0")]
[assembly: AssemblyFileVersion("1.6.1.0")]
4 changes: 2 additions & 2 deletions src/Brutal.Dev.StrongNameSigner/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.1.0")]
[assembly: AssemblyFileVersion("1.5.1.0")]
[assembly: AssemblyVersion("1.6.1.0")]
[assembly: AssemblyFileVersion("1.6.1.0")]

0 comments on commit 7368aa0

Please sign in to comment.