0

I'm setting up a post build event to copy the DLL compiled by Visual Studio into my Unity project, but I can't get it to use the Product Name in the destination path. My command looks like this:

cd $(ProjectDir)
echo F|xcopy /Y "bin\release\$(AssemblyName).dll" "..\..\..\Assets\Plugins\$(ProductName)\$(AssemblyName).dll"

But that puts the file straight in the Plugins directory.

I can use $(RootNamespace) for some projects, but that won't work if I want a space in the folder name.

I know I could just put the product name in manually for each project, but is there a way to get Visual Studio to do it automatically like with the assembly name?

SilentSin
  • 1,026
  • 9
  • 18
  • Why that puts the file straight in the Plugins directory? What's $(ProductName) in your case? I cannot find a marco named "ProductName". – zwcloud Sep 30 '16 at 06:15
  • $(ProductName) is nothing in my case because it doesn't exist as a macro (that's the problem). The path becomes .....Plugins\\$(AssemblyName)..... and so the file goes into Plugins. – SilentSin Sep 30 '16 at 08:16

1 Answers1

0

For C/C++ projects,

Use the Property Manager (in the menu bar: View/Other Windows/Property Manager) to manage your projects' properties.

You can define a custom marco like $(ProjectName) in a new property sheet. And share the property sheet among your projects. Then you can use the marco in the post build event of every project.

For C# projects,

Use the Property Functions.

In Visual Studio 2012 (C#) How to Create Custom Macros available in Post Build

MSBuild: Permanently Change PropertyGroup Property of a Project

By the way, you can use the environment variables if it is good for you.

Community
  • 1
  • 1
zwcloud
  • 4,546
  • 3
  • 40
  • 69
  • The Property Manager is blank and says "No Visual C++ project is loaded". I'm using C# btw. – SilentSin Sep 30 '16 at 08:13
  • That stuff looks like it could probably do what I want so I'll mark your answer as correct, but I won't be using it since it would take far longer to figure out how to get what I need than just putting in the path I want for each project manually. – SilentSin Sep 30 '16 at 09:30