6

Following instructions here, I get the following error:

The attribute "Name" in element is unrecognized

In the .csproj file, I have removed the PostBuild section and replaced it with:

<Target Name="SignOutput" AfterTargets="CoreCompile">
<Exec Command="&quot;C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe&quot; sign /f &quot;$(ProjectDir)My_Cert.pfx&quot; /p mypassword &quot;$(ProjectDir)obj\$(ConfigurationName)\MyExe.exe&quot;" />
</Target>

I'm doing this because I'm getting a “File has a different computed hash than specified in manifest" error" when trying to run a newly published SmartClient application. What is wrong?

Community
  • 1
  • 1
Al Lelopath
  • 6,448
  • 13
  • 82
  • 139
  • 1
    Can't reproduce, the target you show is fine so the cause of the error is elsewhere – stijn Jun 03 '16 at 18:52
  • Are you using VS 2015? Windows 10? – Al Lelopath Jun 03 '16 at 19:12
  • 3
    Neither, but that shouldn't matter. Reading your question again though where you say 'replaced postbuild', I think I found the problem: did you perhaps place the target you show inside a PropertyGroup? Thta's not how it works: it should be defined at the project level – stijn Jun 04 '16 at 07:49
  • Ah, that is the problem. I interpreted the answer (in the question linked to) as replacing `Postbuild` with `Target`. Moving the `Target` to the project level works. Please post that as an answer and I'll check it off. – Al Lelopath Jun 06 '16 at 13:45

1 Answers1

8

The default PostBuildEvent inserted in a csproj is defined as a Property in a PropertyGroup, and it seems you pasted the code for the Target inside that propertyGroup. Not only does that not have the desired effect, it even gives errors loading the project file because properties do not have a Name attribute hence you've got some malformed xml. Resolution: just put the Target at the project level and it will get invoked automatically when building, after CoreCompile but before linking etc, so it's also a way of defining a 'post build event' hence the confusion.

stijn
  • 34,664
  • 13
  • 111
  • 163