-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add support for generating app manifest files for tests #28575
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f21ff25
Add initial support for reading content paths from file
captainsafia 0006122
Add task for generating app manifest file
captainsafia 70d3380
Completed support for generating AppManifest.json
captainsafia 462d919
Fix deserializing JSON and getting path by assembly name
captainsafia d06ce3c
Address feedback from peer review
captainsafia f7ed57e
Fix up target definition and formatting
captainsafia adc15c9
Undo typo fix
captainsafia 656ca5f
Fix target name and JSON parsing
captainsafia 0104914
Update test scenario when using app manifest
captainsafia 6ce42ca
Add new project to ProjectReferences
captainsafia fcf867f
Generate file before PrepareResources
captainsafia e8ef521
Address feedback from peer review
captainsafia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Reflection; | ||
| using System.Runtime.Serialization.Json; | ||
| using System.Text; | ||
| using Microsoft.Build.Framework; | ||
| using Microsoft.Build.Utilities; | ||
|
|
||
| namespace Microsoft.AspNetCore.Mvc.Testing.Tasks | ||
| { | ||
| /// <summary> | ||
| /// Generate a JSON file mapping assemblies to content root paths. | ||
| /// </summary> | ||
| public class GenerateMvcTestManifestTask : Task | ||
| { | ||
| /// <summary> | ||
| /// The path to output the manifest file to. | ||
| /// </summary> | ||
| [Required] | ||
| public string ManifestPath { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// A list of content root paths and assembly names to generate the | ||
| /// manifest from. | ||
| /// </summary> | ||
| [Required] | ||
| public ITaskItem[] Projects { get; set; } | ||
|
|
||
| /// <inheritdoc /> | ||
| public override bool Execute() | ||
| { | ||
| using var fileStream = File.Create(ManifestPath); | ||
| var output = new Dictionary<string, string>(); | ||
|
|
||
| foreach (var project in Projects) | ||
| { | ||
| var contentRoot = project.GetMetadata("ContentRoot"); | ||
| var assemblyName = project.GetMetadata("Identity"); | ||
| output[assemblyName] = contentRoot; | ||
| } | ||
|
|
||
| var serializer = new DataContractJsonSerializer(typeof(Dictionary<string, string>), new DataContractJsonSerializerSettings | ||
| { | ||
| UseSimpleDictionaryFormat = true | ||
| }); | ||
| using var writer = JsonReaderWriterFactory.CreateJsonWriter(fileStream, Encoding.UTF8, ownsStream: false, indent: true); | ||
| serializer.WriteObject(writer, output); | ||
|
|
||
| return !Log.HasLoggedErrors; | ||
| } | ||
| } | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
src/Mvc/Mvc.Testing.Tasks/src/Microsoft.AspNetCore.Mvc.Testing.Tasks.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <Description>Build tasks for functional tests.</Description> | ||
| <TargetFramework>netstandard2.0</TargetFramework> | ||
|
|
||
| <GenerateDocumentationFile>false</GenerateDocumentationFile> | ||
| <AddPublicApiAnalyzers>false</AddPublicApiAnalyzers> | ||
captainsafia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <IsPackable>false</IsPackable> | ||
| <IsShipping>false</IsShipping> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Reference Include="Microsoft.Build.Framework" /> | ||
| <Reference Include="Microsoft.Build.Utilities.Core" /> | ||
| </ItemGroup> | ||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.