Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Compilation options 'CryptoPublicKey' and 'CryptoKeyFile' can't both be specified at the same time. #2452

Closed
JamesNK opened this issue Aug 11, 2015 · 8 comments
Assignees
Labels
Milestone

Comments

@JamesNK
Copy link
Member

JamesNK commented Aug 11, 2015

I'm attempting to dnu build a project.json that has a strong name. If I have a "keyFile" value then I get this error:

Compilation options 'CryptoPublicKey' and 'CryptoKeyFile' can't both be specified at the same time.

If I don't have a keyFile value then the build successfully creates a DLL that is strong named using a key that I didn't specify. I have no idea where it came from.

@JamesNK
Copy link
Member Author

JamesNK commented Aug 11, 2015

I tracked this down to keyFile and strongName being used at the same time with help from http://www.paraesthesia.com/archive/2015/08/06/sign-dnx-assemblies-with-your-key-and-test-in-dnxcore/

This is confusing because the sample here - http://blogs.msdn.com/b/webdev/archive/2015/07/27/announcing-availability-of-asp-net-5-beta-6.aspx - used both of them at once.

Whatever the cause, the error message sucks and is completely unhelpful to anyone who doesn't have deep knowledge of Roslyn.

@moozzyk
Copy link
Contributor

moozzyk commented Aug 11, 2015

@JamesNK the sample in the announcement blog is worng. I already asked @danroth27 to fix it. You can't have both keyFile and strongName in your project.json. See these two issues #2409 #2206 for more details and if you have more questions let me know.

@glennc
Copy link
Member

glennc commented Aug 11, 2015

Closing, since it is an error in the post. I'll see about getting someone to update the blog post today, otherwise @danroth27 is back tomorrow.

@glennc glennc closed this as completed Aug 11, 2015
@JamesNK
Copy link
Member Author

JamesNK commented Aug 11, 2015

Why are you closing this? The error message given to the user should say you can't use keyFile and strongName at the same time. The current one doesn't help them.

@Eilon Eilon reopened this Aug 11, 2015
@Eilon
Copy link
Member

Eilon commented Aug 11, 2015

Oh whoops, we must've misunderstood the issue then.

So the error message is simply wrong?

@moozzyk
Copy link
Contributor

moozzyk commented Aug 11, 2015

The message is technically correct but it comes directly from the compiler so does not relate to settings in the project.json and therefore may not be useful.

// If both CryptoPublicKey and CryptoKeyFile compilation will fail so we don't need a check

@danroth27
Copy link
Member

Blog post should be updated now.

moozzyk pushed a commit that referenced this issue Oct 14, 2015
If project json contains the `keyFile` property the assembly should
be signed using the provided snk. However real signing is not
supported on Mono. Currently we just error out in this case, after
this change we will fall back to using OSS signing. (Fixes #2558)

Also adding a warning for a case where if both `strongName` and `keyFile`
settings are provided we would just display errors from Roslyn which might
be hard to understand/troubleshoot because the names used in the errors
are different from the names we use in project.json (Fixes #2452)
moozzyk pushed a commit that referenced this issue Oct 19, 2015
…eClr

If the project.json file contains the `keyFile` on CoreClr and Mono we
will extract the public key from the snk file and will OSS sign the
assembly with the extracted key. (Fixes #2558). We will do the same on
desktop CLR if the `keyFile` option is accompanied by `"useOssSigning": true`

As a result of this change the `keyFile` and the `useOssSigning` are
no longer mutually exclusive and we will no show cyptic Roslyn
compilation errors we would have shown before. (Fixes #2452).
moozzyk pushed a commit that referenced this issue Oct 20, 2015
…eClr

If the project.json file contains the `keyFile` on CoreClr and Mono we
will extract the public key from the snk file and will OSS sign the
assembly with the extracted key. (Fixes #2558). We will do the same on
desktop CLR if the `keyFile` option is accompanied by `"useOssSigning": true`

As a result of this change the `keyFile` and the `useOssSigning` are
no longer mutually exclusive and we will no show cyptic Roslyn
compilation errors we would have shown before. (Fixes #2452).
@moozzyk moozzyk added this to the 1.0.0-rc1 milestone Oct 20, 2015
@moozzyk moozzyk self-assigned this Oct 20, 2015
@moozzyk
Copy link
Contributor

moozzyk commented Oct 20, 2015

We will now extract the public key from the snk and will sign the assembly with this key. We won't get the error anymore since now using both options is valid. (only strongName was renamed to useOssSigning)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants