質問

I have a VS2012 project. To make it run I need a hosts file entry eg. 127.0.0.1 local.mywebsite.com

The problem is I want to make it as easy as possible for new developers to simply get the project from TFS and run it without any extra steps.

Is it possible for me to execute a post-build event which can add that entry to my hosts file if that entry doesn't exist already?

役に立ちましたか?

解決 2

Answering my own question:

  1. Visual Studio-->Open Nuget Console and run this command : Install-Package MSBuild.Extension.Pack
  2. Visual Studio-->Right Click-->Unload your Project (.csproj)
  3. Afer unloading you can now Right Click-->Edit .csproj
  4. Scroll down all the way and paste these lines before the ending "Project" tag -->http://pastebin.com/eEJXDrmi
  5. Save .csproj and right click -->reload project

You are good to go !!!! Now, when you build your project it will update your hosts files if that entry exists, and will create the entry if it doesn't exist. Pretty Cool stuff !

他のヒント

You can achieve that by extending the build process using MSBuild. Call WriteLinesToFile Task wrapped in AfterBuild target. Alternatively you can write your own custom MSBuild Task.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top