Precompiling an ASP.NET Web Application with MSBuild

I have a C # web application project in Visual Studio 2008 that I want to precompile for deployment. After looking at the various options, it seems that they all have some problems - perhaps someone could provide their thoughts on this:

The project is under source control and also contains many files excluded from the project.

Web deployment projects don't work. If I try to use wdp to compile, aspnet_compiler.exe will try to compile all excluded files as well. I do not want to include a list of exceptions in the msbuild script.

Is there a way to tell msbuild to only use the files / items specified in the csproj file, copy them to an intermediate folder and create an aspnet_complier.exe file from that copy that doesn't contain any excluded files?

The website has options for 3 other csproj files.

Thank!

+2


source to share


2 answers


You can create msbuild tasks to hide (+ h attribute) or delete unneeded 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 solution file (.sln) and build your csproj and build it.



Ps. Not really your problem, but this might help (for websites, not web apps):

Can't publish with msbuild or aspnet_compiler with cc.net

+1


source


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



Suggestion: Run the compiler on deployment or delete files

0


source







All Articles