3

我在 Azure Worker 角色项目中使用 PostSharp 3 Ultimate。我正在使用tfs.visualstudio.com源代码控制。

现在,PostSharp 不喜欢NuGet Package Restore. 它要求我们在构建服务器上构建项目之前恢复所有 nuget 包 -- http://doc.postsharp.net/##nuget-restore

所以,我点击了这个链接(http://docs.nuget.org/docs/reference/package-restore-with-team-build)并创建了一个.proj文件,首先恢复所有 NuGet 包,然后在构建服务器上构建解决方案. 这种方法非常适合我ASP .Net MVC部署为Azure Web Site. 但是当我尝试以Azure Worker相同的方式构建我的项目时,我收到以下错误:

Exception Message: Please specify a Visual Studio Solution (.sln) to build. (type BuildFromSolutionException)
Exception Stack Trace:    at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

以下是我的解决方案的结构:

+ Solution
|-+ packages
|-+ Tools
| |-+ NuGet
|   |-- NuGet.exe
|-+ Workers (Cloud Project)
|-+ Workers.QueueProcessor (Worker Role)
|-- Workers.Build.proj
|-- Workers.sln

这是Workers.Build.proj我签入到 TFS 的新文件中的内容:

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

    <PropertyGroup>
        <OutDir>$(MSBuildThisFileDirectory)bin</OutDir>
        <Configuration>Release</Configuration>
        <ProjectProperties>
            OutDir=$(OutDir);
            Configuration=$(Configuration);
        </ProjectProperties>
    </PropertyGroup>

    <ItemGroup>
        <Solution Include="$(MSBuildThisFileDirectory)Workers.sln" />
    </ItemGroup>

    <Target Name="RestorePackages">
        <Exec Command="$(MSBuildThisFileDirectory)Tools\NuGet\NuGet.exe restore $(MSBuildThisFileDirectory)Workers.sln" />
    </Target>

    <Target Name="Clean">
        <MSBuild Targets="Clean"
            Projects="@(Solution)"
            Properties="$(ProjectProperties)" />
    </Target>

    <Target Name="Build" DependsOnTargets="RestorePackages">
        <MSBuild Targets="Build"
            Projects="@(Solution)"
            Properties="$(ProjectProperties)" />
    </Target>

    <Target Name="Rebuild" DependsOnTargets="RestorePackages">
        <MSBuild Targets="Rebuild"
            Projects="@(Solution)"
            Properties="$(ProjectProperties)" />
    </Target>
</Project>
4

0 回答 0