[SalesForce] Deploying via the Migration Tool With a Managed Package Failing Due to Namespace

I'm new to the Migration Tool and I'm having an issue deploying my managed package code to a developer org. The error I'm getting says:

The specified package namespace: NAMESPACE does not match the namespace for the server

Since namespaces are specific to an org is it possible to deploy this code?

Thanks,
tim

Best Answer

We are using DevOrgs with different namespaces as part of our development process. I have described parts of it as an answer to Best practices for Versioning managed packages in Git. In our experience it is the best to:

  1. Never hardcode references to the namespace in your code. If the namespace is really needed, it could be determined by a custom object or field of your package and comparing getName() vs. getLocalName()
  2. Use a branch or something similar to separate your DevOrgs with different namespaces.
  3. Replace the namespace reference at the package.xml by something generic like <namespacePrefix>PREFIX</namespacePrefix> and replace it before deploy and after retrieve. The real namespace could be stored at the build.properties file
  4. Create a unique namespace for the target DevOrg before the first deployment and put it into the build.properties. We are using our JIRA story keys for that (e.g. FOO-2346 key results in FOO_2346 namespace).
Related Topic