我正在构建一个项目,该项目使用C ++后端来处理速度和Java UI,并在Apache .NET Ant库中使用名为“msbuild”的Ant任务构建后端二进制文件:
http://ant.apache.org/antlibs/dotnet/
但我似乎无法找到“msbuild”任务支持的元素的任何文档。我想尝试不同的控制台记录器参数。
那里有一些我根本找不到的文件吗?或者有没有办法确定“msbuild”任务支持的属性和嵌套元素而无需阅读文档?
答案 0 :(得分:1)
它可能只是Msbuild.exe的包装器。随每个版本的框架提供。
MSBuild命令行参考
http://msdn.microsoft.com/en-us/library/vstudio/ms164311%28v=vs.80%29.aspx
屏幕截图(来自您的链接)显示“2.0”,这意味着它可能是以下内容的包装:
C:\的Windows \ Microsoft.NET \框架\ V2.0.50727 \ msbuild.exe
..............
如果你有一个包装msbuild.exe的自定义任务,那么希望你能找到该自定义任务的源代码。 这将讲述实施者(自定义任务)实际上“编码”的故事。
我在自定义任务中发现的是,实现者将放置大部分/部分整体属性,但不是全部属性。
其中(如果你能掌握原始资源),你可以获得代码并根据需要添加额外的属性。
..............
如果您无法获取源代码.........然后使用反射器(我喜欢ILSpy)来查看可在您的任务上设置的属性。 (如果您的自定义任务是用java编写的,则为java等效项)
...... 请记住,在一天结束时,自定义任务只是命令行的超级花哨包装器。 您在自定义任务上设置属性,并且任务的代码将其放入命令行窗体。 拿一粒盐,但这通常是命令行工具包装器的作用。 我没有看到原始的源代码,但我强烈猜测这是发生了什么。
编辑:
获取源代码:
当前位置:
http://www.gtlib.gatech.edu/pub/apache//ant/antlibs/dotnet/source/apache-ant-dotnet-1.1-src.zip
或从这里开始:
http://ant.apache.org/antlibs/srcdownload.cgi
弄清楚源代码在做什么。
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.ant.dotnet.build;
import java.io.File;
import java.util.List;
import org.apache.ant.dotnet.util.CollectionUtils;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Runs a MSBuild build process.
*/
public class MSBuildTask extends AbstractBuildTask {
private static final String TARGET = "generated-by-ant";
private static final String ROOT = "Project";
private static final String MSBUILD_NS =
"http://schemas.microsoft.com/developer/msbuild/2003";
public MSBuildTask() {
super();
}
protected String getExecutable() {
return "MSBuild.exe";
}
protected String[] getBuildfileArguments(File buildFile) {
if (buildFile != null) {
return new String[] {
buildFile.getAbsolutePath()
};
} else {
return new String[0];
}
}
protected String[] getTargetArguments(List targets) {
if (targets.size() > 0) {
StringBuffer sb = new StringBuffer("/target:");
sb.append(CollectionUtils.flattenToString(targets, ";"));
return new String[]{sb.toString()};
} else {
return new String[0];
}
}
protected String[] getPropertyArguments(List properties) {
if (properties.size() > 0) {
StringBuffer sb = new StringBuffer("/property:");
sb.append(CollectionUtils.flattenToString(properties, ";"));
return new String[]{sb.toString()};
} else {
return new String[0];
}
}
/**
* Turn the DocumentFragment into a DOM tree suitable as a build
* file when serialized.
*
* <p>If we have exactly one <Project> child, return that.
* Otherwise if we have only <Task> children, wrap them into a
* <Target> which in turn gets wrapped into a <Project>.
* Otherwise, fail.</p>
*/
protected Element makeTree(DocumentFragment f) {
NodeList nl = f.getChildNodes();
if (nl.getLength() == 1
&& nl.item(0).getNodeType() == Node.ELEMENT_NODE
&& nl.item(0).getNodeName().equals(ROOT)) {
return (Element) nl.item(0);
} else {
Element p = f.getOwnerDocument().createElementNS(MSBUILD_NS,
ROOT);
p.setAttribute("DefaultTargets", TARGET);
Element t = f.getOwnerDocument().createElementNS(MSBUILD_NS,
"Target");
t.setAttribute("Name", TARGET);
p.appendChild(t);
t.appendChild(f);
return p;
}
}
}