2

I have a visual studio solution that has, amongst other project the following three:

  • NamespacePrefix.NancyFX.csproj: Some Nancy modules
  • NamespacePrefix.NancyFX.IISHosting.csproj: A web solution to host the nancy modules
  • NamespacePrefix.NancyFX.Selfhost.csproj: An exe to host the nancy modules

In addition to rest services there is some html javascript and css in the Views/, Scripts/, and Content/ folders. I want this content in both the IIS Hosting and the Self hosting project. Currently I store the files in the Web project, and copy them over to the self hosting project bu editing the csproj xml like so:

<Target Name="BeforeBuild">                                                                                            
  <ItemGroup>                                                                                                          
    <ContentItems Include="..\NamespacePrefix.NancyFX.IISHosting\Content\**\*.*" />                                     
    <ScriptItems Include="..\NamespacePrefix.NancyFX.IISHosting\Scripts\**\*.*" />                                      
    <ViewItems Include="..\NamespacePrefix.NancyFX.IISHosting\Views\*.*" />                                             
  </ItemGroup>                                                                                                         
  <Copy SourceFiles="@(ContentItems)" DestinationFiles="$(TargetDir)\Content\%(RecursiveDir)%(Filename)%(Extension)" />
  <Copy SourceFiles="@(ScriptItems)" DestinationFiles="$(TargetDir)\Scripts\%(RecursiveDir)%(Filename)%(Extension)" /> 
  <Copy SourceFiles="@(ViewItems)" DestinationFolder="$(TargetDir)\Views" />                                           
</Target>                                                                                                              

This works fine, but is there a better way? This seems to give me the best intellisense, etc.

migrated from codereview.stackexchange.com Jan 20 '14 at 21:05

This question came from our site for peer programmer code reviews.

  • Is it not enough to reference the same folders/files by using Add -> Existing item... option? – Konrad Kokosa Jan 20 '14 at 16:18
  • 2
    This question appears to be off-topic because it is not about reviewing code. Might be a better fit for Programmers.SE. – Mathieu Guindon Jan 20 '14 at 16:31
  • 1
    @Malachi how is this a superuser question? I'm hand editing a .csproj file, which is written in msbuild. Msbuild is a turing complete declarative DSL that runs from the command line and Visual Studio. Despite it being just a DSL, I can call any CLR method from it. I have working code, but I want to see if I'm doing it the best way. That seems like a code review question. If not, its a stackoverflow question. – Justin Dearing Jan 20 '14 at 16:59
  • 2
    I guess a build XML-file is a border case between Programmers and Code Review. I don't think this is a SO question since you don't have an actual problem, but just want to know if there's a better way. I personally feel that your question is more related to the structure of your solution than actual code, and therefore I think you should try Programmers. If you don't get any help there (which I doubt), let us know and your question will likely be re-opened. Otherwise, feel free to start a discussion about this on our Software Engineering Meta. – Simon Forsberg Jan 20 '14 at 17:20
  • @JustinDearing, I reread the question, it's not a superuser question, I should't skim so fast, it is a Programmers question though. this is about design and not about review of code, does that make sense? – Malachi Jan 20 '14 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.