English 中文(简体)
How do I use MSBuild on a C# project with no compilable code
原标题:
  • 时间:2009-11-19 23:07:29
  •  标签:
  • msbuild

I have a C# web app project which actually has no ASP.Net or C# in it. It s just a single html page with some Javascript, CSS, and a couple of images.

I want to use MSBuild to deploy a version of this app to an output folder with minified JS and CSS.

With the following code, I get an error "CSC: fatal error CS2008: No inputs specified." I m guessing because the there is no actual C# code to compile but I m not sure.

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
    <PropertyGroup>
        <CssTidy>..uild_toolscsstidy.exe</CssTidy>
    </PropertyGroup>

    <PropertyGroup>
        <DeploymentFolder>Test</DeploymentFolder>
        <SourceProject>....TestTest.csproj</SourceProject>
    </PropertyGroup>

    <Import Project="Common.Web.targets" />

    <ItemGroup>
        <CssFiles Include="....TestCSSstylesheet.css" />
        <ScriptFiles Include="....TestJavaScriptjavascript.js"/>
    </ItemGroup>

    <Target Name="compress_css">
        <Attrib Files="%(CssFiles.FullPath)" ReadOnly="false"/>
        <Exec Command="$(CssTidy) %(CssFiles.FullPath) %(CssFiles.FullPath) --template=highest" />
    </Target>

    <Target Name="compress_js">
        <Attrib Files="%(ScriptFiles.FullPath)" ReadOnly="false"/>
        <JSCompress Files="%(ScriptFiles.FullPath)"></JSCompress>
    </Target>

    <Target Name="call_targets">
        <CallTarget Targets="compress_css"/>
        <CallTarget Targets="compress_js"/>
    </Target>
</Project> 

How can I accomplish this?

问题回答

You could override the CoreCompile target and do nothing there:<Target name="CoreCompile" />. This will skip its activities and move on. You may have to override additional targets to avoid errors.

At the top of the file you have the DefaultTargets="Build"

Change "Build" to "call_targets" and you should be good to go.

What is inside "common.web.targets"? I assume that the error is generated from a target in that file (or another that it imports).

A quick fix for this would be to add a dummy page to the project. The build would work after that.





相关问题
How can I overwrite file web.config with web.other.config?

I have a msbuild script with custom logic to deploy my service to the qa server automatically. I have to overwrite the default config with a dedicated one, but when I use <Copy SourceFiles="web....

How do I use MSBuild on a C# project with no compilable code

I have a C# web app project which actually has no ASP.Net or C# in it. It s just a single html page with some Javascript, CSS, and a couple of images. I want to use MSBuild to deploy a version of ...

您能否防止MSBuild.exe经营活动?

我用文字建造一些项目,偶尔利用习俗制造事件,给建筑系统造成了很大困难。 如果有可能,我想援引MSBuild.exe。

building .net applications without Visual Studio

I m interested to hear about people working with building .net applications using MSBuild, NAnt or similar tools. What are you using, why are you using it instead of the VS IDE? I like to use ...

How long does my Visual Studio C# compile take?

It seems like it should be possible to configure Visual Studio to print out how long the compile takes. Perhaps somewhere in the .sln file. If the sln is compiled from the command line using ...

热门标签