Editing “testproject.zip” to stop “UnitTest1.cs” being created

倾然丶 夕夏残阳落幕 提交于 2019-12-24 00:33:19

问题


I've been modifying the VS2010 item and project templates so each time we do a "new project" or "new item" we get it created in a format that works for us. This is all working fine; if we create a new class library we get it with the references we've set up and it doesn't create the "class1.cs" file - that all works. We've made a similar change to the TestProject.zip file that lives in:

C:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\ProjectTemplates\CSharp\Test\1033

Gone through the same process of zipping it back up, copying it over top of the original and refreshing the cache. However for the test project we can't stop it creating the default "unittest1.cs" file. All of our other changes to the test project are working fine but we just can't stop it creating the "unittest1.cs" file. It was never in the template or csproj file originally so I'm not sure what is creating it.

Can anyone help? What creates the default test file for the test project - I'm wondering if it's a reference to the wizard that is in the template file but have no idea what changes would be needed.


回答1:


  1. Close Visual Studio
  2. Extract BasicUnitTest.zip from:

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\1033

  3. Open BasicUnitTest.vstemplate

  4. Remove <ProjectItem ReplaceParameters="true">UnitTest.cs</ProjectItem>

  5. Zip BasicUnitTest.vstemplate into BasicUnitTest.zip (excluding UnitTest.cs)
  6. Go to:

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache\CSharp\1033

  7. Delete UnitTest.cs and replace BasicUnitTest.vstemplate with your modified copy

  8. On the next run of Visual Studio you should see the modified UnitTest

Though you can do this for every default template, I recommend creating a new template based on the BasicUnitTest.zip instead of overriding the ones shipped with Visual Studio. It's easier, safer and won't be overwritten by future service packs.



来源:https://stackoverflow.com/questions/9435485/editing-testproject-zip-to-stop-unittest1-cs-being-created

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!