我想爲Visual Studio 2013自定義UnitTest項目模板:我們經常在UnitTest項目中使用Moq,因此我認爲它應該被自動引用。Visual Studio 2013項目模板定製
在C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ProjectTemplates\CSharp\Test\1033\UnitTestProject
,我通過添加參考區段和一個的ItemGroup編輯UnitTestProject.csproj
:
<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>
然後我添加的文件packages.config到該文件夾,並通過加入
<ProjectItem ReplaceParameters="false" TargetFileName="packages.config">packages.config</ProjectItem>
編輯UnitTestProject.vstemplate
到項目部分。
但是,當我創建一個新的單元測試項目中,我得到錯誤信息
The file packages.config could not be found within the project templates. Continuing to run, but the resulting project may not build properly.
單擊確定後,另一條錯誤消息如下:
Unable to copy the file 'packages.config' from the project template to the project. Cannot find file "(%TEMP%\some folder)\packages.config'.
那怎麼可以解決?