[
https://issues.apache.org/jira/browse/CB-12163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15748839#comment-15748839
]
ASF GitHub Bot commented on CB-12163:
-------------------------------------
Github user ktop commented on a diff in the pull request:
https://github.com/apache/cordova-windows/pull/213#discussion_r92438038
--- Diff: template/cordova/lib/PluginHandler.js ---
@@ -53,18 +53,37 @@ var handlers = {
},
'resource-file':{
install:function(obj, plugin, project, options) {
- // do not copy, but reference the file in the plugin folder.
This allows to
- // have multiple source files map to the same target and
select the appropriate
- // one based on the current build settings, e.g. architecture.
- // also, we don't check for existence. This allows to insert
build variables
- // into the source file name, e.g.
- // <resource-file src="$(Platform)/My.dll" target="My.dll" />
- var relativeSrcPath = getPluginFilePath(plugin, obj.src,
project.projectFolder);
- project.addResourceFileToProject(relativeSrcPath, obj.target,
getTargetConditions(obj));
+ var targetConditions = getTargetConditions(obj);
+ if (targetConditions.reference) {
+ // do not copy, but reference the file in the plugin
folder. This allows to
+ // have multiple source files map to the same target and
select the appropriate
+ // one based on the current build settings, e.g.
architecture.
+ // also, we don't check for existence. This allows to
insert build variables
+ // into the source file name, e.g.
+ // <resource-file src="$(Platform)/My.dll" target="My.dll"
/>
+ var relativeSrcPath = getPluginFilePath(plugin, obj.src,
project.projectFolder);
+ project.addResourceFileToProject(relativeSrcPath,
obj.target, targetConditions);
+ } else {
+ // if target already exists, emit warning to consider
using a reference instead of copying
+ if (fs.existsSync(path.resolve(project.root, obj.target)))
{
+ events.emit('warn', '<resource-file> with target ' +
obj.target + ' already exists and will be overwritten ' +
+ 'by a <resource-file> with the same target. Consider
using the attribute reference="true" in the ' +
+ '<resource-file> tag to avoid overwriting files with
the same target. ');
--- End diff --
I agree it would make it clearer for users.
> plugin.xml 'resource-file' does not copy file to target for Windows
> -------------------------------------------------------------------
>
> Key: CB-12163
> URL: https://issues.apache.org/jira/browse/CB-12163
> Project: Apache Cordova
> Issue Type: Bug
> Components: Windows
> Affects Versions: Master
> Environment: Windows 8/Windows10
> Reporter: Karen Tran
> Assignee: Karen Tran
> Labels: Windows
>
> From plugin.xml:
> {noformat}<resource-file src="windows/shared/myprops.properties"
> target="myprops.properties"/>{noformat}
> <resource-file> does not copy the file from src to target anymore. It used
> to, but was changed. This creates a couple of issues since I expect it to be
> in the application, but it technically isn't. This means that I cannot update
> the file that doesn't exist and very much limits the functionality of
> <resource-file> (Also the documentation is wrong for Windows since it doesn't
> copy any files). Visual Studio also only shows the file from the src path.
> This doesn't make much sense since that file wouldn't be in the application.
> The expected behavior should be if the target is specified, <resource-file>
> should copy the file to the target location. In turn, Visual Studio should
> show the target file instead of the src file because the target is part of
> the application whereas the src file is not.
> This used to be expected behavior, but was changed as a result of CB-10326.
> The intention of that issue is limited to use cases of only having the src
> attribute, ignoring the possibility that we would want to update files in the
> target instead (which imo makes more sense). Resource files are not all .dll
> files, so it's not very user friendly to limit the <resource-file> tag to
> handling just those kinds of files.
> Proposed changes in JsprojManager.js and PluginHandler.js:
> If target attribute is specified, copy the file to the target and point the
> Include attribute to the path of the target.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]