NascarEd
NascarEd

Reputation: 1390

Project file with just files and no built output

How can I make a project file (VS 2008) that just has some data files in and has no built output?

I can make an empty project and add my data files to it (which get copied to the output folder ), but it produces an EmptyProject.dll after I do a build. I want just my data files in the output directory and not some empty DLL or EXE.

I want the data files to be the only thing in this project as the project will be shared in a couple of solutions.

Our application is C#. All of our normal code projects are C#.

The data files are schemas (XSD). I want these schemas to be in the output folder, but I don't want them included with an existing project. I would like a project named "Schemas" that has nothing in except the XSD files and does nothing except copy the XSD files to the output folder. I would like this in a project file so that the same schemas project can be referenced in multiple solutions.

Upvotes: 11

Views: 5133

Answers (5)

Paurian
Paurian

Reputation: 1402

Possibly another way is editing the csproj file by replacing this:

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

with this:

  <Target Name="Build" />
  <Target Name="Rebuild" />

Then builds don't create anything. It worked for me. Same general idea should work for any xxproj file. Just replace the <Import Project...> tags with the <Target...> tags.

I'd be interested in knowing if this causes any issues or doesn't work for anyone.

Upvotes: 2

Mark Conway
Mark Conway

Reputation: 492

Great stuff. Expanding on Scott > Daniel's answer:

  • Safe to remove all References and Properties (AssemblyInfo.cs)
  • If it is a node/grunt/gulp project then you can invoke it in your Build Events > *Post-build event command line * eg: gulp build or gulp clean
  • Perhaps you can add removal or obj and bin output folders to your node/grunt/gulp clean scripts mitigating the need for del $(TargetPath)

Upvotes: 0

Daniel Rose
Daniel Rose

Reputation: 17648

Expanding on Scott's answer:

  1. Create a new project of type Empty project
  2. In Properties->Application, change Output type to Class Library
  3. In Properties->Build->Advanced, change Debug Info to None
  4. In Properties->Build Events, set the Post-build event command line to del $(TargetPath)

That way, the project creates only a DLL, which gets deleted. At the same time, the "copy to output directory" settings on your data files is respected.

Upvotes: 3

Scott Ewers
Scott Ewers

Reputation: 664

I don't know of a way to suppress the creation of the .dll file. BUT... here's an easy workaround. In the project properties, Build Events tab, write a Post-build event command line that will delete the file. Something like:

del path\filename.dll

Upvotes: 4

Assaf Lavie
Assaf Lavie

Reputation: 75983

What do you need a project for if you're not building it?

  1. You can use solution folders to "store" files...
  2. Why not just disable building this project for all configurations (use the Configuration Manager) - that way it won't build.

Upvotes: 0

Related Questions