简体   繁体   English

更改DeploymentItem的名称

[英]Changing the name of a DeploymentItem

I am using DeploymentItem s to deploy test files. 我使用DeploymentItem来部署测试文件。 I was wondering if it was possible to change the name of the deployed file in the deployed location instead of just doing a copy. 我想知道是否可以在部署位置更改已部署文件的名称,而不是仅仅进行复制。 For example: 例如:

[DeploymentItem("path/to/my/file/test.txt", "testfiles/somethingelse.txt")]

It would deploy test.txt but it would rename the file to somethingelse.txt. 它将部署test.txt但它会将文件重命名为somethingelse.txt。

Or do I just have to do this manually using the File I/O API before I run my actual test? 或者,在运行实际测试之前,我是否必须使用File I / O API手动执行此操作?

It appears that this is not possible. 看来这是不可能的。 One must copy files manually during test setup. 必须在测试设置期间手动复制文件。

http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.deploymentitemattribute.aspx http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.deploymentitemattribute.aspx

(Optional) Target directory path must be a folder, and it is relative to the deployment directory. (可选)目标目录路径必须是文件夹,并且它与部署目录相关。 If the folder does not exist, it will be created. 如果该文件夹不存在,则将创建该文件夹。 The default value is the deployment directory. 默认值是部署目录。 You cannot change the file name by using DeploymentItem. 您无法使用DeploymentItem更改文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM