views:

575

answers:

2

I have a c# web application project in Visual Studio 2008 that I want to precompile for deployment. After looking at various options, it seems all of them have some issues - perhaps someone could give their thoughts on this:

The project is under source control and also contains a lot of files that are excluded from project.

Web Deployment Projects does not work. If I try to use a wdp to compile, aspnet_compiler.exe will also try to compile all the excluded files. I don't want to maintain an exclude list in the msbuild script.

Is there a way to tell msbuild only to use the files/items that are specified in the csproj file, copy these to an intermediate folder and have aspnet_complier.exe build from this copy that does not contain any of the excluded files?

The website has depencies to 3 other csproj files.

Thanks!

A: 

Any reason you can't run aspnet_compiler.exe as part of your deployment script instead?
Why are the files there if they aren't used?

Suggestion: Run the compiler on deployment or remove the files

Hightechrider
+1  A: 

Hi!

You can make msbuild tasks to hide (attrib +h) or delete unwanted files...

  <PropertyGroup>
    <MyLogFile>kaantologi.txt</MyLogFile>
    <MyWebSourcePath>c:\sourecontrol\myweb</MyWebSourcePath>
    <!-- *.tmp and .exclude and etc: -->
    <MyCleaup>
      attrib $(MyWebSourcePath)\*.tmp -r -s -h -a /s >>$(MyLogFile)
      del $(MyWebSourcePath)\*.tmp /q /s >>$(MyLogFile)
      attrib $(MyWebSourcePath)\*.exclude +h
    </MyCleaup>
  </PropertyGroup>
  <Target Name="MyClean">
    <Exec Command="$(MyCleaup)" />
  </Target>
  <Target Name="MyFinal">
    <Exec Command="attrib $(MyWebSourcePath)\*.exclude -h"/>
  </Target>
  <Target Name="MyBuild">
    <CallTarget Targets="MyClean" />
    <CallTarget Targets="MyCompile" /><!--...-->
    <CallTarget Targets="MyFinal" />
  </Target>

Or you can use a solution file (.sln) and have your csproj there and build that.

Ps. Not exactly your problem, but this might help (it is for web sites, not for web applications):

http://stackoverflow.com/questions/887883/unable-to-publish-using-msbuild-or-aspnetcompiler-using-cc-net/1873643#1873643

Tuomas Hietanen