`DeploymentItem` is not os-independant in combination with folders
See original GitHub issueDescribe the bug
Hi,
I hope I am at the right repository for this. If not, please point me to the right one.
DeploymentItem
is not os-independant when using it with folders. The folder name must end with /
on linux and \
on windows.
Thank you.
Steps To Reproduce
Example files:
TestFiles1/some_file1
TestFiles2/some_file2
MyTests.cs
MyTests.csproj
// MyTests.cs
[TestClass]
public class MyTests
{
[TestMethod]
[DeploymentItem(@"TestFiles1/")]
public void TestFailsOnWindows()
{
var fs = File.Open(@"some_file1", FileMode.Open);
}
[TestMethod]
[DeploymentItem(@"TestFiles2\")]
public void TestFailsOnLinuxMac()
{
var fs = File.Open(@"some_file2", FileMode.Open);
}
}
<!--MyTests.csproj-->
<!--...-->
<ItemGroup>
<Content Include="TestFiles1\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestFiles2\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expected behavior
Using either \
or /
on windows, linux or mac should always work.
Actual behavior
Files are not copied to the test directory and the test fails if the wrong format is used.
Additional context
None.
Issue Analytics
- State:
- Created 9 months ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
c# - DeploymentItem not deploying files
I have to open a file which I'm deploying using DeploymentItem attribute . But it is not deploying file to the Test deployment...
Read more >DeploymentItem Metadata - Windows drivers
Deploys all items and directories found within the C:\\MyDataFiles\\MyDataFiles2\\ directory. This configuration does not create the MyDataFiles ...
Read more >DeploymentItem results are inconsistent - Build/Test Issues
DeploymentItem results are inconsistent: I have two unit tests in the same file in the same project which each use the same attributes....
Read more >Testlocation with DeploymentItem inconsistent - Build/Test ...
It seems to have to do with the location of the directory the testrunner uses, which is varying (maybe dependent on the last...
Read more >DeploymentItemAttribute Class
Copies the contents of TestFiles into a subfolder of the deployment folder. Subfolders are replicated under the destination. [DeploymentItem(@".
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am reopening the issue to confirm this use case is also working (the deployment item part is not well tested).
Thank you @Evangelink !