我有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
通过更改YUICompressor.targets中的使用任务,我在http://support.appharbor.com/discussions/problems/3629-yuicompresoor-msbuild-task尝试了建议:
<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),那么解决方案的构建没有错误。
我做错了什么?
答案 0 :(得分:1)
我认为最好使用property functions。
<PropertyGroup>
<YuiCompressorDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\Bin'))</YuiCompressorDir>
</PropertyGroup>
<UsingTask TaskName="CompressorTask" AssemblyFile="$(YuiCompressorDir)\Yahoo.Yui.Compressor.MsBuildTask.dll" />
您可以查看来自example项目的直播 ASP.NET Web Stack。