0

I'd like to customize the UnitTest project template for Visual Studio 2013: We use Moq very often in UnitTest projects, hence I think it should be automatically referenced.

In C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ProjectTemplates\CSharp\Test\1033\UnitTestProject, I edited UnitTestProject.csproj by adding a reference section and an ItemGroup:

<ItemGroup>
    <None Include="packages.config" />
</ItemGroup>
...
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
  <HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
  <Private>True</Private>
</Reference>

Then I added the file packages.config to that folder, and edited UnitTestProject.vstemplate by adding

<ProjectItem ReplaceParameters="false" TargetFileName="packages.config">packages.config</ProjectItem>

to the Project section.

But when I create a new UnitTest project, I get the error message

The file packages.config could not be found within the project templates. Continuing to run, but the resulting project may not build properly.

After clicking OK, another error message follows:

Unable to copy the file 'packages.config' from the project template to the project. Cannot find file "(%TEMP%\some folder)\packages.config'.

How can that be solved?

Bernhard Hiller
  • 2,163
  • 2
  • 18
  • 33

1 Answers1

0

Beyond changing the template in C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ProjectTemplates, I had to replace it also in C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ProjectTemplatesCache. Next, I had to look into %AppData%\C:\Users\bernhard.hiller\AppData\Roaming\Microsoft\VisualStudio\12.0\ProjectTemplatesCache and delete the zip-file for the template.

Now the packages.config file gets copied when I add a new Unit Test Project manually. But when using the "Unit Test Generator" (see https://visualstudiogallery.msdn.microsoft.com/45208924-e7b0-45df-8cff-165b505a38d7), this file is missing while all other changes to the project (post build actions, references, ...) are applied.

Bernhard Hiller
  • 2,163
  • 2
  • 18
  • 33