Nat*_*end 4 asp.net msbuild publish visual-studio pubxml
我试图在 ASP.NET 文件系统发布中包含一个未包含在解决方案中的文件(它是从构建后脚本自动生成的)。根据这些说明,我应该能够.pubxml使用<_CustomFiles>元素在我的定义中添加对文件的引用。这是我的.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>
Run Code Online (Sandbox Code Playgroud)
第二个<PropertyGroup>和<Target>元素是我添加的。
但是,Visual Studio 无法识别该<_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'
Run Code Online (Sandbox Code Playgroud)
为什么 Visual Studio 无法识别此元素?我需要更改什么才能将此文件包含在我的文件系统发布中?
弄清楚了。我误解了<_CustomFiles>元素的用途。似乎这是一个自定义元素(即不是 XML 模式的一部分,因此是 VS 警告)用于将信息传递给<FilesForPackaginFromProject>它下面的元素。
事实证明,这种方法是为我工作,我只是使用相对路径不正确。
| 归档时间: |
|
| 查看次数: |
1247 次 |
| 最近记录: |