我试图在ASP.NET文件系统发布中包含一个不包含在解决方案中的文件(它是从构建后脚本自动生成的)。根据这些指示,我应该能够使用.pubxml元素在.pubxml定义中添加对文件的引用。下面是我的.pubxml文件的样子:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>(publish URL here)</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="scripts\app.min.js" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Extra Files\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
</Project>第二个<PropertyGroup>和<Target>元素是由我添加的。
但是,Visual没有识别<_CustomFiles>元素,并且该文件也没有包含在发布中。注意元素下面的绿色线条:

当我悬停在上面时,会显示以下错误消息:
The element 'ItemGroup' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element '_CustomFiles' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'为什么Visual无法识别此元素?为了将这个文件包含在我的文件系统发布中,我需要更改什么?
发布于 2015-07-18 20:02:20
弄明白了。我误解了<_CustomFiles>元素的用途。这似乎是一个自定义元素(即不是XML的一部分,因此是VS警告),用于将信息传递给它下面的<FilesForPackaginFromProject>元素。
原来这个方法对我有用,我只是简单地不正确地使用相对路径。
https://stackoverflow.com/questions/31483974
复制相似问题