question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`DeploymentItem` is not os-independant in combination with folders

See original GitHub issue

Describe 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:closed
  • Created 9 months ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Evangelinkcommented, Jul 4, 2023

I am reopening the issue to confirm this use case is also working (the deployment item part is not well tested).

1reaction
smorokincommented, Jul 4, 2023

Thank you @Evangelink !

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found