Nuget软件包的增量构建 [英] Incremental Build of Nuget Packages
问题描述
我想执行一个msbuild项目,该项目使用批处理来确定已经重新构建了一个或多个csproj
项目,因此需要新的nuget打包.到目前为止,我编写的脚本似乎是一个合理的开始,但是它的增量构建机制无法正常工作. MainBuild
目标无论何时都将执行.
I want to execute an msbuild project which uses batching to determine that one or more csproj
projects have been freshly-built, and therefore require fresh nuget packaging. The script I've made so far seems like a reasonable start, but it the incremental-build mechanism isn't working. The MainBuild
target executes every time, no matter what.
这就是我所拥有的:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="MainBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)'=='' ">Debug</Configuration>
<Content>content\plugins\</Content>
</PropertyGroup>
<ItemGroup>
<Nuspec Include="$(MSBuildProjectDirectory)\plugins\*\*.nuspec" />
</ItemGroup>
<Target Name="MainBuild"
Inputs="%(Nuspec.RootDir)%(Nuspec.Directory)bin\$(Configuration)\*.dll"
Outputs="%(Nuspec.RootDir)%(Nuspec.Directory)%(FileName).pkg" >
<ItemGroup>
<Inputs Include="%(Nuspec.RootDir)%(Nuspec.Directory)bin\$(Configuration)\*.dll" />
<Outputs Include="%(Nuspec.RootDir)%(Nuspec.Directory)%(FileName).pkg" />
</ItemGroup>
<Message Text="INPUTS: %(Inputs.FullPath)" />
<Message Text="OUTPUTS: @(Outputs->'%(FullPath)')" />
<Copy SourceFiles="@(Inputs)" DestinationFiles="@(Outputs->'%(FullPath)')" />
</Target>
</Project>
Copy
任务只是一个调试占位符,用于调出nuget并创建一个新包.
The Copy
task is just a debugging placeholder for calling-out to nuget and creating a new package.
这个想法是,如果bin\Debug
目录中的任何文件比相应的.nuspec文件(在bin\Debug
上方的两个文件夹中)都新,则MainBuild
目标应执行.
The idea is that if any files in the bin\Debug
directory are newer than the corresponding .nuspec file (found two folders above bin\Debug
), then the MainBuild
target should execute.
有什么想法吗?
p.s.假定Target
的Inputs
和Outputs
属性各自创建一个项目.我认为创建的项目无法在目标内部引用很奇怪.在上面的示例中,我必须创建一个target-interna动态ItemGroup来重新创建项目,以便可以访问它们.有办法解决吗?
p.s. The Inputs
and Outputs
attributes of the Target
presumably each create an item. I think it strange that the items created can't be referenced inside the target. In the above example, I had to make a target-interna dynamic ItemGroup to re-create the items, just so that I could access them. Is there a way around that?