Skip to content

Setting up a new project

JohnThomson edited this page Sep 25, 2012 · 11 revisions

This page discusses various aspects of adding a new project to FieldWorks. Don't do this lightly...we have too many already! But if you need to...

Setting up AssemblyInfo

The following should be done when creating a new project:

  • Edit the default AssemblyInfo.cs, remove all but the AssemblyTitle and ComVisible lines. (You can keep AssemblyDescription if it is useful.) Generally change ComVisible to false.

  • Add a link to src/CommonAssemblyInfo.cs

IMPORTANT: Adding a file like src/CommonAssemblyInfo.cs which is not in the project’s own folder must be done in a special way. If you just add it as you would normally add an existing file, VS will add a COPY of the file to the project’s own folder. The version info will then NOT be updated automatically, which will cause problems when building patch installers.

The correct procedure is to add it almost as usual (right-click the project, choose Add/Existing Item, Navigate to the file and select it), but instead of double-clicking or just clicking Add, click the pull-down arrow on the Add button and select Add as Link.

You can verify that it was done right using a diff on the .csproj file. The addition should look like this:

CommonAssemblyInfo.cs

Also, there should NOT be a new CommonAssemblyInfo.cs file in your project folder.

Do NOT do this for test assemblies...there is no reason for them to link to CommonAssemblyInfo, as it is there to insert information we want in shipping DLLs.

Custom build steps

If your project needs some special build action that can't be set up with the VS UI, our preferred approach is to add a BuildIncude.targets file to the project containing the additional build steps. You can find many examples of these to work with. To get these targets to take effect:

  • Right-click the project in solution explorer and choose "Unload project".
  • Right-click again and choose "Edit X.csproj".
  • Insert

after the line

(If you put it earlier, your special targets like AfterBuild will be ignored in favor of the empty ones defined in the standard CSharp.targets.)

  • Put whatever you need in buildInclude.targets. Here's an outline:
  • Right-click the project, select Reload project.
  • Exit Visual Studio and restart it
  • Build the project and verify your special steps work.

Note that if you have to debug the script, typically you will have to restart Visual Studio every time you make a change in order to see the results. Alternatively you can build from a command line.

Clone this wiki locally