0
votes

I am trying to perform registration of the DLL which was created during Build.

In project properties -> Build Events -> Post-Build-Event i have added the below command to perform registration,

regsvr32 /s /c "$(TargetPath)"

Post-Build-Event Dialog

This command is used to perform registration of the DLL specified in Target Path. When i try to Build my code, i am facing following error,

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): 

error MSB3073: The command "regsvr32 /s /c "D:\Project\Debug\x64\SDK.dll"

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): 

error MSB3073: :VCEnd" exited with code 3.

On clicking the error, it navigates to below tags within Microsoft.CppCommon.targets

 <Target Name="PostBuildEvent" Condition="'$(PostBuildEventUseInBuild)'!='false'">
<Message Text="%(PostBuildEvent.Message)" Condition="'%(PostBuildEvent.Message)' != '' and '%(PostBuildEvent.Command)' != ''" Importance="High" />
<Exec Command="%(PostBuildEvent.Command)$(_BuildSuffix)" Condition="'%(PostBuildEvent.Command)' != ''"/>

I searched for error MSB3073: :VCEnd" exited with code 3 in few links and found that it occurs when the path specified is invalid or could not be found.

However, the path of the DLL was in the location i specified. I even tried to provide absolute path of DLL within the Post-Build-Event. Yet i'm facing same error.

Am i missing something while performing Post-Build-Event or is there anything to do with regsvr32 command?

1
That's not the problem, but the regsvr32 /c switch hasn't worked since NT4 times.dxiv
I think your dll project is dynamic library project and the project does not have ID. When you want to register a dll, you should make sure that the project has ID. So this type of project cannot be used as DLLs that will to be registered.Mr Qian
You can try to use ATL projects as dll projects and you can check my answer.Mr Qian
@PerryQian-MSFT Hi, Thanks for the answer. Seems like issue is w.r.t COM dll being used and additional library dependencies which are not linked to COM dll as expected. The project is too old and is in optimisation phase. Here, we need to use already implemented DLL project to resolve this issue. Also we could find few legacy issues as you mentioned. I would try implementing DLLRegisterServer and check if the issue could be resolved. Thank youSharath Kumar
@SharathKumar, any update about this issue? Since your old project is wrt com project, I suggest you could create a new one in VS2017(the new one has been updated in VS2017 and works well with the command). Then migrate your old project into it. It can save you a lot of time and avoid several errors.Mr Qian

1 Answers

1
votes

MSB3073 exited with code 3 - Post Build Event in Visual Studio 2017

The issue is related to your dynamic library project and not related to VS.

And when you want to register a com dll, the dll project should contain a ID to register into system. However, the dynamic library project does not have the ID by default. So this type of project cannot used as DLLs that will to be registered.

If you still want to use dynamic library project, you should implement DllRegisterServer to add the ID.

You can use ATL projects which contain the ID as dll projects .

This is a similar issue about it.

Solution

1) Instead, you should create ATL projects.

2) Then, in the command, you should remove /c which was abandoned so far.

Or use like this command:

regsvr32 /n /i "$(TargetPath)" as command in post-build event.

=====================

Update 1

Since your project is an old WRT project, you can just create a new WRT runtime component project in VS2017 and then migrate the content of your old project into the new one. It will save you a lot of time and avoid a lot of tedious mistakes.

1) Please install C++/WinRT vs extension first.

2) Then create a new windows runtime componment project and then migrate your old project's content into the new one.

enter image description here

In my side, the project can works well with command regsvr32 /n /i "$(TargetPath)".