2

我有 YUICompressor.NET,http://yuicompressor.codeplex.com/,配置为 msbuild 任务,它在我的开发机器上按预期工作。

当我将代码推送到 AppHarbor 时,我收到以下构建错误:

D:\temp\q2hapsex.50d\input\Projects\CroquetScores.Web\Build\YUICompressor.targets(21,9):
error MSB4062: The "CompressorTask" task could not be loaded from the assembly
D:\temp\q2hapsex.50d\input\Projects\CroquetScores.Web\Build\..\Bin\Yahoo.Yui.Compressor.MsBuildTask.dll.
Could not load file or assembly
'file:///D:\temp\q2hapsex.50d\input\Projects\CroquetScores.Web\Bin\Yahoo.Yui.Compressor.MsbuildTask.dll' 
or one of its dependencies. The system cannot find the file specified. 
Confirm that the <UsingTask> declaration is correct, that the assembly and all its
dependencies are available, and that the task contains a public class that implements
Microsoft.Build.Framework.ITask

我已经尝试了http://support.appharbor.com/discussions/problems/3629-yuicompresoor-msbuild-task的建议,方法是将 YUICompressor.targets 中的 using 任务更改为:

<UsingTask TaskName="CompressorTask" AssemblyFile="..\Bin\Yahoo.Yui.Compressor.MsBuildTask.dll" />

<UsingTask TaskName="CompressorTask" AssemblyFile="$(OutDir)Yahoo.Yui.Compressor.MsBuildTask.dll" />

我使用以下命令在本地机器上测试设置:

msbuild AppHarbor.sln /property:Configuration=Release /property:OutDir=D:\temp\TestingAppHarbor\

但除了路径信息外,它会导致相同的错误:

D:\Code\croquetscores.com\Projects\CroquetScores.Web\Build\YUICompressor.targets(21,9): 
error MSB4062: The "CompressorTask" task could not be loaded from the assembly
D:\Code\croquetscores.com\Projects\CroquetScores.Web\Build\Yahoo.Yui.Compressor.MsBuildTask.dll. 
Could not load file or assembly
'file:///D:\Code\croquetscores.com\Projects\CroquetScores.Web\Build\Yahoo.Yui.Compressor.MsBuildTask.dll'
or one of its dependencies. The system cannot find the file specified. 
Confirm that the <UsingTask> declaration is correct, that the assembly and all its
dependencies are available, and that the task contains a public class that implements
Microsoft.Build.Framework.ITask. 

如果我将 YUICompressor.targets 中的 $(OutDir) 替换为实际路径,则解决方案的构建不会出错。

我究竟做错了什么?

4

1 回答 1

1

我认为使用属性函数会更好。

<PropertyGroup>
    <YuiCompressorDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\Bin'))</YuiCompressorDir>
</PropertyGroup>
<UsingTask TaskName="CompressorTask" AssemblyFile="$(YuiCompressorDir)\Yahoo.Yui.Compressor.MsBuildTask.dll" />

您可以查看来自ASP.NET Web Stack项目的实时 示例。

于 2012-07-25T21:14:59.993 回答