New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@MsBuild [DeploymentItem] - added option to provide output directory #901
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,7 +147,10 @@ public void AddFeatureFile(string featureFileText, string featureFileName = null | |
|
||
public ContentFileInput AddContentFile(string fileName, string fileContent) | ||
{ | ||
var contentFileInput = new ContentFileInput(fileName, fileContent); | ||
var file = Path.GetFileName(fileName); | ||
var directory = Path.GetDirectoryName(fileName); | ||
|
||
var contentFileInput = string.IsNullOrEmpty(directory) || directory == "." ? new ContentFileInput(file, fileContent) : new ContentFileInput(file, fileContent, directory); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please refactor this to a separate method |
||
ContentFiles.Add(contentFileInput); | ||
return contentFileInput; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ public Project GenerateProject(InputProjectDriver inputProjectDriver) | |
foreach (var contentFileInput in inputProjectDriver.ContentFiles) | ||
{ | ||
string outputPath = Path.Combine(inputProjectDriver.CompilationFolder, contentFileInput.ProjectRelativePath); | ||
new FileInfo(outputPath).Directory?.Create(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about System.IO.Directory.CreateDirectory(Path.GetDirectoryName(outputPath)) ? |
||
File.WriteAllText(outputPath, contentFileInput.Content, Encoding.UTF8); | ||
project.AddItem("Content", contentFileInput.ProjectRelativePath, new[] | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,57 @@ Scenario: Should be able to deploy files | |
</TestSettings> | ||
""" | ||
When I execute the tests with MsTest | ||
Then the execution summary should contain | ||
| Succeeded | | ||
| 1 | | ||
|
||
@config | ||
Scenario: Should be able to deploy files to specific folder | ||
Given there is a SpecFlow project | ||
And the following binding class | ||
""" | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[Binding] | ||
public class DeploymentItemSteps | ||
{ | ||
[Then(@"the file '(.*)' exists")] | ||
public void ThenTheFileExists(string fileName) | ||
{ | ||
Assert.IsTrue(File.Exists(fileName)); | ||
} | ||
} | ||
""" | ||
And there is a feature file in the project as | ||
""" | ||
@MsTest:DeploymentItem:TestXmls\:TestXmls | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use a different name for folder and file in this example? |
||
Feature: Deployment Item Feature | ||
|
||
Scenario: Deployment Item Scenario | ||
Then the file 'TestXmls\DeploymentItemTestFile.txt' exists | ||
""" | ||
And there is a content file 'TestXmls\DeploymentItemTestFile.txt' in the project as | ||
""" | ||
This is a deployment item file | ||
""" | ||
And the specflow configuration is | ||
""" | ||
<specFlow> | ||
<unitTestProvider name="MsTest"/> | ||
</specFlow> | ||
""" | ||
And there is a test settings file 'Local.testsettings' | ||
""" | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TestSettings | ||
id="b8f2810b-cd53-4519-8b18-d0e599219d54" | ||
name="Local" | ||
enableDefaultDataCollectors="false" | ||
xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> | ||
<Deployment enabled="true" /> | ||
</TestSettings> | ||
""" | ||
When I execute the tests with MsTest | ||
Then the execution summary should contain | ||
| Succeeded | | ||
| 1 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please invert the if