Merge branch 'rel/1.0.0' into dev/mlorbe/UpdateCSharpWebTemplatesForSdkAttribute
This commit is contained in:
commit
0e55a41f69
42 changed files with 349 additions and 247 deletions
|
@ -2,6 +2,6 @@
|
|||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<Sdk Include="Microsoft.Net.Sdk" Version="$(CLI_NETSDK_Version)" />
|
||||
<Sdk Include="Microsoft.NET.Sdk" Version="$(CLI_NETSDK_Version)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,5 +1,4 @@
|
|||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -14,14 +13,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>$(CLI_NETSDK_Version)</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NETStandard.Library">
|
||||
<Version>1.6.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -14,14 +13,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>$(CLI_NETSDK_Version)</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NETStandard.Library">
|
||||
<Version>1.6.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -14,14 +13,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>$(CLI_NETSDK_Version)</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NETStandard.Library">
|
||||
<Version>1.6.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
Outputs="@(SdkContent->'$(SdkLayoutDirectory)/%(RecursiveDir)%(FileName)%(Extension)')">
|
||||
<Copy SourceFiles="@(SdkContent)"
|
||||
DestinationFiles="@(SdkContent->'$(SdkLayoutDirectory)/%(RecursiveDir)%(FileName)%(Extension)')" />
|
||||
|
||||
<Message Text="Copied Sdk $(SdkPackageName) from $(SdkNuPkgPath) to $(SdkLayoutDirectory)."
|
||||
Importance="High" />
|
||||
</Target>
|
||||
|
||||
<Target Name="GetSdkItemsToCopy">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<ItemGroup>
|
||||
<!-- CLI cannot use the latest SDK until we move away from SDK PackageRef -->
|
||||
<BundledSdk Include="NuGet.Build.Tasks.Pack" Version="4.0.0-rc2" />
|
||||
<BundledSdk Include="Microsoft.Net.Sdk" Version="1.0.0-alpha-20161203-1" />
|
||||
<BundledSdk Include="Microsoft.NET.Sdk" Version="1.0.0-alpha-20161203-1" />
|
||||
<BundledSdk Include="Microsoft.NET.Sdk.Web" Version="$(CLI_WEBSDK_Version)" />
|
||||
<BundledSdk Include="Microsoft.NET.Sdk.Publish" Version="$(CLI_WEBSDK_Version)" />
|
||||
<BundledSdk Include="Microsoft.NET.Sdk.Web.ProjectSystem" Version="$(CLI_WEBSDK_Version)" />
|
||||
|
|
|
@ -251,7 +251,7 @@
|
|||
<Properties>
|
||||
CLIBuildDll=$(CLIBuildDll);
|
||||
NuGetPackagesDir=$(NuGetPackagesDir);
|
||||
SdkLayoutDirectory=$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity);
|
||||
SdkLayoutDirectory=$(SdkOutputDirectory)/Sdks/%(BundledSdk.Identity);
|
||||
SdkPackageName=%(BundledSdk.Identity);
|
||||
SdkPackageVersion=%(BundledSdk.Version);
|
||||
Stage0Directory=$(Stage0Directory)
|
||||
|
@ -260,7 +260,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<MSBuild
|
||||
BuildInParallel="True"
|
||||
BuildInParallel="False"
|
||||
Projects="@(SdksToBundle)">
|
||||
</MSBuild>
|
||||
</Target>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CLI_MSBuild_Version>15.1.0-preview-000451-02</CLI_MSBuild_Version>
|
||||
<CLI_MSBuild_Version>15.1.0-preview-000454-01</CLI_MSBuild_Version>
|
||||
<CLI_NETSDK_Version>1.0.0-alpha-20161104-2</CLI_NETSDK_Version>
|
||||
<CLI_WEBSDK_Version>1.0.0-alpha-20161104-2-112</CLI_WEBSDK_Version>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -12,5 +12,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
|||
public const string MstestTestAdapterVersion = "1.1.3-preview";
|
||||
public const string MstestTestFrameworkVersion = "1.0.4-preview";
|
||||
public const string BundleMinifierToolVersion = "2.2.301";
|
||||
public const string WebSdkPackageVersion = "1.0.0-alpha-20161117-1-119" ;
|
||||
}
|
||||
}
|
|
@ -13,18 +13,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
|||
public string ProjectXProjFilePath { get; }
|
||||
public string ProjectDirectory { get; }
|
||||
public string OutputDirectory { get; }
|
||||
public string SdkPackageVersion { get; }
|
||||
public ProjectRootElement MSBuildProjectTemplate { get; }
|
||||
public string SdkDefaultsFilePath { get; }
|
||||
|
||||
public MigrationSettings(
|
||||
string projectDirectory,
|
||||
string outputDirectory,
|
||||
string sdkPackageVersion,
|
||||
ProjectRootElement msBuildProjectTemplate,
|
||||
string projectXprojFilePath=null,
|
||||
string sdkDefaultsFilePath=null) : this(
|
||||
projectDirectory, outputDirectory, sdkPackageVersion, projectXprojFilePath, sdkDefaultsFilePath)
|
||||
projectDirectory, outputDirectory, projectXprojFilePath, sdkDefaultsFilePath)
|
||||
{
|
||||
MSBuildProjectTemplate = msBuildProjectTemplate != null ? msBuildProjectTemplate.DeepClone() : null;
|
||||
}
|
||||
|
@ -32,11 +30,10 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
|||
public MigrationSettings(
|
||||
string projectDirectory,
|
||||
string outputDirectory,
|
||||
string sdkPackageVersion,
|
||||
string msBuildProjectTemplatePath,
|
||||
string projectXprojFilePath=null,
|
||||
string sdkDefaultsFilePath=null) : this(
|
||||
projectDirectory, outputDirectory, sdkPackageVersion, projectXprojFilePath, sdkDefaultsFilePath)
|
||||
projectDirectory, outputDirectory, projectXprojFilePath, sdkDefaultsFilePath)
|
||||
{
|
||||
_msBuildProjectTemplatePath = msBuildProjectTemplatePath;
|
||||
MSBuildProjectTemplate = ProjectRootElement.Open(
|
||||
|
@ -48,13 +45,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
|||
private MigrationSettings(
|
||||
string projectDirectory,
|
||||
string outputDirectory,
|
||||
string sdkPackageVersion,
|
||||
string projectXprojFilePath=null,
|
||||
string sdkDefaultsFilePath=null)
|
||||
{
|
||||
ProjectDirectory = projectDirectory;
|
||||
OutputDirectory = outputDirectory;
|
||||
SdkPackageVersion = sdkPackageVersion;
|
||||
ProjectXProjFilePath = projectXprojFilePath;
|
||||
SdkDefaultsFilePath = sdkDefaultsFilePath;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
|||
var projectDir = Path.GetDirectoryName(project.ProjectFilePath);
|
||||
var settings = new MigrationSettings(projectDir,
|
||||
projectDir,
|
||||
rootSettings.SdkPackageVersion,
|
||||
tempMSBuildProjectTemplate);
|
||||
MigrateProject(settings);
|
||||
projectMigrationReports.Add(MigrateProject(settings));
|
||||
|
|
|
@ -39,16 +39,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
|||
|
||||
var noFrameworkPackageReferenceItemGroup = migrationRuleInputs.OutputMSBuildProject.AddItemGroup();
|
||||
|
||||
// Inject Sdk dependency
|
||||
_transformApplicator.Execute(
|
||||
SdkPackageDependencyTransform.Transform(
|
||||
new PackageDependencyInfo
|
||||
{
|
||||
Name = PackageConstants.SdkPackageName,
|
||||
Version = migrationSettings.SdkPackageVersion,
|
||||
PrivateAssets = "All"
|
||||
}), noFrameworkPackageReferenceItemGroup, mergeExisting: false);
|
||||
|
||||
AddProjectTypeSpecificDependencies(
|
||||
migrationRuleInputs,
|
||||
migrationSettings,
|
||||
|
@ -90,18 +80,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
|||
var type = project.GetProjectType();
|
||||
switch (type)
|
||||
{
|
||||
case ProjectType.Web:
|
||||
_transformApplicator.Execute(
|
||||
SdkPackageDependencyTransform.Transform(
|
||||
new PackageDependencyInfo
|
||||
{
|
||||
Name = PackageConstants.WebSdkPackageName,
|
||||
Version = migrationSettings.SdkPackageVersion,
|
||||
PrivateAssets = "All"
|
||||
}),
|
||||
noFrameworkPackageReferenceItemGroup,
|
||||
mergeExisting: false);
|
||||
break;
|
||||
case ProjectType.Test:
|
||||
_transformApplicator.Execute(
|
||||
PackageDependencyInfoTransform().Transform(
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.Build.Construction;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||
{
|
||||
//HACK to workaround https://github.com/Microsoft/msbuild/issues/1429
|
||||
internal class MigrateWebSdkRule : IMigrationRule
|
||||
{
|
||||
private static string GetContainingFolderName(string projectDirectory)
|
||||
{
|
||||
projectDirectory = projectDirectory.TrimEnd(new char[] { '/', '\\' });
|
||||
return Path.GetFileName(projectDirectory);
|
||||
}
|
||||
|
||||
public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
|
||||
{
|
||||
var project = migrationRuleInputs.DefaultProjectContext.ProjectFile;
|
||||
var type = project.GetProjectType();
|
||||
|
||||
if(type == ProjectType.Web)
|
||||
{
|
||||
ReplaceSdkWithWebSdk(migrationSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReplaceSdkWithWebSdk(MigrationSettings migrationSettings)
|
||||
{
|
||||
string csprojName = $"{GetContainingFolderName(migrationSettings.ProjectDirectory)}.csproj";
|
||||
var outputProject = Path.Combine(migrationSettings.OutputDirectory, csprojName);
|
||||
|
||||
var csprojContent = File.ReadAllText(outputProject);
|
||||
csprojContent = csprojContent.Replace("Sdk=\"Microsoft.NET.Sdk\"", "Sdk=\"Microsoft.NET.Sdk.Web\"");
|
||||
|
||||
File.WriteAllText(outputProject, csprojContent);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
namespace Microsoft.DotNet.Tools
|
||||
{
|
||||
internal class LocalizableStrings
|
||||
internal class CommonLocalizableStrings
|
||||
{
|
||||
public const string CouldNotFindAnyProjectInDirectory = "Could not find any project in `{0}`.";
|
||||
public const string MoreThanOneProjectInDirectory = "Found more than one project in `{0}`. Please specify which one to use.";
|
||||
|
@ -29,6 +29,9 @@
|
|||
public const string Library = "Library";
|
||||
public const string Program = "Program";
|
||||
public const string Application = "Application";
|
||||
public const string ReferenceDoesNotExist = "Reference {0} does not exist. If you still want to add it, please use --force option. Please note that this may have adverse effects on the project. ";
|
||||
public const string ReferenceAddedToTheProject = "Reference `{0}` added to the project.";
|
||||
|
||||
|
||||
// Verbs
|
||||
public const string Add = "Add";
|
||||
|
@ -112,13 +115,6 @@
|
|||
public const string SolutionDoesNotExist = "Specified solution file {0} does not exist, or there is no solution file in the directory.";
|
||||
public const string SolutionAlreadyContainsAProject = "Solution {0} already contains project {1}.";
|
||||
|
||||
/// add p2p
|
||||
public const string ReferenceDoesNotExist = "Reference {0} does not exist. If you still want to add it, please use --force option. Please note that this may have adverse effects on the project. ";
|
||||
public const string ReferenceIsInvalid = "Reference `{0}` is invalid.";
|
||||
public const string SpecifyAtLeastOneReferenceToAdd = "You must specify at least one reference to add. Please run dotnet add --help for more information.";
|
||||
public const string ReferenceAddedToTheProject = "Reference `{0}` added to the project.";
|
||||
public const string ProjectAlreadyHasAReference = "Project {0} already has a reference `{1}`.";
|
||||
|
||||
/// add package
|
||||
public const string PackageReferenceDoesNotExist = "Package reference `{0}` does not exist.";
|
||||
public const string PackageReferenceIsInvalid = "Package reference `{0}` is invalid.";
|
||||
|
@ -134,13 +130,6 @@
|
|||
public const string ProjectAddedToTheSolution = "Project `{0}` added to the solution.";
|
||||
public const string SolutionAlreadyHasAProject = "Solution {0} already contains project {1}.";
|
||||
|
||||
/// del p2p
|
||||
public const string ReferenceNotFoundInTheProject = "Specified reference {0} does not exist in project {1}.";
|
||||
public const string ReferenceRemoved = "Reference `{0}` deleted from the project.";
|
||||
public const string SpecifyAtLeastOneReferenceToRemove = "You must specify at least one reference to delete. Please run dotnet delete --help for more information.";
|
||||
public const string ReferenceDeleted = "Reference `{0}` deleted.";
|
||||
public const string SpecifyAtLeastOneReferenceToDelete = "You must specify at least one reference to delete. Please run dotnet delete --help for more information.";
|
||||
|
||||
/// del pkg
|
||||
public const string PackageReferenceNotFoundInTheProject = "Package reference `{0}` could not be found in the project.";
|
||||
public const string PackageReferenceRemoved = "Reference `{0}` deleted from the project.";
|
|
@ -34,7 +34,7 @@ namespace Microsoft.DotNet.Tools
|
|||
}
|
||||
else if (args.Length == 1)
|
||||
{
|
||||
Reporter.Error.WriteLine(string.Format(LocalizableStrings.RequiredArgumentNotPassed, "<command>").Red());
|
||||
Reporter.Error.WriteLine(string.Format(CommonLocalizableStrings.RequiredArgumentNotPassed, "<command>").Red());
|
||||
Reporter.Output.WriteLine(HelpText);
|
||||
return 1;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace Microsoft.DotNet.Tools
|
|||
return builtin(args);
|
||||
}
|
||||
|
||||
Reporter.Error.WriteLine(string.Format(LocalizableStrings.RequiredArgumentIsInvalid, "<command>").Red());
|
||||
Reporter.Error.WriteLine(string.Format(CommonLocalizableStrings.RequiredArgumentIsInvalid, "<command>").Red());
|
||||
Reporter.Output.WriteLine(HelpText);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ namespace Microsoft.DotNet.Tools
|
|||
{
|
||||
if (!File.Exists(projectPath))
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.ProjectDoesNotExist, projectPath);
|
||||
throw new GracefulException(CommonLocalizableStrings.ProjectDoesNotExist, projectPath);
|
||||
}
|
||||
|
||||
var project = TryOpenProject(projectPath);
|
||||
if (project == null)
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.ProjectIsInvalid, projectPath);
|
||||
throw new GracefulException(CommonLocalizableStrings.ProjectIsInvalid, projectPath);
|
||||
}
|
||||
|
||||
return new MsbuildProject(project);
|
||||
|
@ -62,36 +62,36 @@ namespace Microsoft.DotNet.Tools
|
|||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.CouldNotFindProjectOrDirectory, projectDirectory);
|
||||
throw new GracefulException(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, projectDirectory);
|
||||
}
|
||||
|
||||
if (!dir.Exists)
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.CouldNotFindProjectOrDirectory, projectDirectory);
|
||||
throw new GracefulException(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, projectDirectory);
|
||||
}
|
||||
|
||||
FileInfo[] files = dir.GetFiles("*proj");
|
||||
if (files.Length == 0)
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.CouldNotFindAnyProjectInDirectory, projectDirectory);
|
||||
throw new GracefulException(CommonLocalizableStrings.CouldNotFindAnyProjectInDirectory, projectDirectory);
|
||||
}
|
||||
|
||||
if (files.Length > 1)
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.MoreThanOneProjectInDirectory, projectDirectory);
|
||||
throw new GracefulException(CommonLocalizableStrings.MoreThanOneProjectInDirectory, projectDirectory);
|
||||
}
|
||||
|
||||
FileInfo projectFile = files.First();
|
||||
|
||||
if (!projectFile.Exists)
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.CouldNotFindAnyProjectInDirectory, projectDirectory);
|
||||
throw new GracefulException(CommonLocalizableStrings.CouldNotFindAnyProjectInDirectory, projectDirectory);
|
||||
}
|
||||
|
||||
var project = TryOpenProject(projectFile.FullName);
|
||||
if (project == null)
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.FoundInvalidProject, projectFile.FullName);
|
||||
throw new GracefulException(CommonLocalizableStrings.FoundInvalidProject, projectFile.FullName);
|
||||
}
|
||||
|
||||
return new MsbuildProject(project);
|
||||
|
@ -106,14 +106,14 @@ namespace Microsoft.DotNet.Tools
|
|||
{
|
||||
if (Project.HasExistingItemWithCondition(framework, @ref))
|
||||
{
|
||||
Reporter.Output.WriteLine(string.Format(LocalizableStrings.ProjectAlreadyHasAreference, @ref));
|
||||
Reporter.Output.WriteLine(string.Format(CommonLocalizableStrings.ProjectAlreadyHasAreference, @ref));
|
||||
continue;
|
||||
}
|
||||
|
||||
numberOfAddedReferences++;
|
||||
itemGroup.AppendChild(Project.CreateItemElement(ProjectItemElementType, @ref));
|
||||
|
||||
Reporter.Output.WriteLine(string.Format(LocalizableStrings.ReferenceAddedToTheProject, @ref));
|
||||
Reporter.Output.WriteLine(string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @ref));
|
||||
}
|
||||
|
||||
return numberOfAddedReferences;
|
||||
|
@ -157,7 +157,7 @@ namespace Microsoft.DotNet.Tools
|
|||
throw new GracefulException(
|
||||
string.Join(
|
||||
Environment.NewLine,
|
||||
notExisting.Select((r) => string.Format(LocalizableStrings.ReferenceDoesNotExist, r))));
|
||||
notExisting.Select((r) => string.Format(CommonLocalizableStrings.ReferenceDoesNotExist, r))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,13 +176,13 @@ namespace Microsoft.DotNet.Tools
|
|||
}
|
||||
|
||||
numberOfRemovedRefs++;
|
||||
Reporter.Output.WriteLine(string.Format(LocalizableStrings.ProjectReferenceRemoved, r));
|
||||
Reporter.Output.WriteLine(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, r));
|
||||
}
|
||||
}
|
||||
|
||||
if (numberOfRemovedRefs == 0)
|
||||
{
|
||||
Reporter.Output.WriteLine(string.Format(LocalizableStrings.ProjectReferenceCouldNotBeFound, reference));
|
||||
Reporter.Output.WriteLine(string.Format(CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, reference));
|
||||
}
|
||||
|
||||
return numberOfRemovedRefs;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||
{
|
||||
internal class LocalizableStrings
|
||||
{
|
||||
public const string ReferenceIsInvalid = "Reference `{0}` is invalid.";
|
||||
|
||||
public const string SpecifyAtLeastOneReferenceToAdd = "You must specify at least one reference to add. Please run dotnet add --help for more information.";
|
||||
|
||||
public const string ProjectAlreadyHasAReference = "Project {0} already has a reference `{1}`.";
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
|||
app.OnExecute(() => {
|
||||
if (string.IsNullOrEmpty(projectArgument.Value))
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.RequiredArgumentNotPassed, "<Project>");
|
||||
throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, "<Project>");
|
||||
}
|
||||
|
||||
var msbuildProj = MsbuildProject.FromFileOrDirectory(projectArgument.Value);
|
|
@ -8,41 +8,41 @@ namespace Microsoft.DotNet.Tools.Help
|
|||
{
|
||||
public class HelpCommand
|
||||
{
|
||||
private const string UsageText = @"Usage: dotnet [host-options] [command] [arguments] [common-options]
|
||||
private static readonly string UsageText = $@"{LocalizableStrings.Usage}: dotnet [host-options] [command] [arguments] [common-options]
|
||||
|
||||
Arguments:
|
||||
[command] The command to execute
|
||||
[arguments] Arguments to pass to the command
|
||||
[host-options] Options specific to dotnet (host)
|
||||
[common-options] Options common to all commands
|
||||
{LocalizableStrings.Arguments}:
|
||||
[command] {LocalizableStrings.CommandDefinition}
|
||||
[arguments] {LocalizableStrings.ArgumentsDefinition}
|
||||
[host-options] {LocalizableStrings.HostOptionsDefinition}
|
||||
[common-options] {LocalizableStrings.OptionsDescription}
|
||||
|
||||
Common options:
|
||||
-v|--verbose Enable verbose output
|
||||
-h|--help Show help
|
||||
{LocalizableStrings.CommonOptions}:
|
||||
-v|--verbose {LocalizableStrings.VerboseDefinition}
|
||||
-h|--help {LocalizableStrings.HelpDefinition}
|
||||
|
||||
Host options (passed before the command):
|
||||
-v|--verbose Enable verbose output
|
||||
--version Display .NET CLI Version Number
|
||||
--info Display .NET CLI Info
|
||||
{LocalizableStrings.HostOptions}:
|
||||
-v|--verbose {LocalizableStrings.VerboseDefinition}
|
||||
--version {LocalizableStrings.VersionDescription}
|
||||
--info {LocalizableStrings.InfoDescription}
|
||||
|
||||
Commands:
|
||||
new Initialize a basic .NET project
|
||||
restore Restore dependencies specified in the .NET project
|
||||
build Builds a .NET project
|
||||
publish Publishes a .NET project for deployment (including the runtime)
|
||||
run Compiles and immediately executes a .NET project
|
||||
test Runs unit tests using the test runner specified in the project
|
||||
pack Creates a NuGet package
|
||||
migrate Migrates a project.json based project to a msbuild based project
|
||||
{LocalizableStrings.Commands}:
|
||||
new {LocalizableStrings.NewDefinition}
|
||||
restore {LocalizableStrings.RestoreDefinition}
|
||||
build {LocalizableStrings.BuildDefinition}
|
||||
publish {LocalizableStrings.PublishDefinition}
|
||||
run {LocalizableStrings.RunDefinition}
|
||||
test {LocalizableStrings.TestDefinition}
|
||||
pack {LocalizableStrings.PackDefinition}
|
||||
migrate {LocalizableStrings.MigrateDefinition}
|
||||
|
||||
Project modification commands:
|
||||
add Add items to the project
|
||||
remove Remove items from the project
|
||||
|
||||
Advanced Commands:
|
||||
nuget Provides additional NuGet commands
|
||||
msbuild msbuilds a project and all of its dependencies
|
||||
vstest Runs tests from the specified files";
|
||||
{LocalizableStrings.AdvancedCommands}:
|
||||
nuget {LocalizableStrings.NugetDefinition}
|
||||
msbuild {LocalizableStrings.MsBuildDefinition}
|
||||
vstest {LocalizableStrings.VsTestDefinition}";
|
||||
|
||||
public static int Run(string[] args)
|
||||
{
|
||||
|
|
61
src/dotnet/commands/dotnet-help/LocalizableStrings.cs
Normal file
61
src/dotnet/commands/dotnet-help/LocalizableStrings.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
namespace Microsoft.DotNet.Tools.Help
|
||||
{
|
||||
internal class LocalizableStrings
|
||||
{
|
||||
public const string Usage = "Usage";
|
||||
|
||||
public const string Arguments = "Arguments";
|
||||
|
||||
public const string CommandDefinition = "The command to execute";
|
||||
|
||||
public const string ArgumentsDefinition = "Arguments to pass to the command";
|
||||
|
||||
public const string HostOptionsDefinition = "Options specific to dotnet (host)";
|
||||
|
||||
public const string OptionsDescription = "Options common to all commands";
|
||||
|
||||
public const string CommonOptions = "Common options";
|
||||
|
||||
public const string VerboseDefinition = "Enable verbose output";
|
||||
|
||||
public const string HelpDefinition = "Show help";
|
||||
|
||||
public const string HostOptions = "Host options (passed before the command)";
|
||||
|
||||
public const string VersionDescription = "Display .NET CLI Version Number";
|
||||
|
||||
public const string InfoDescription = "Display .NET CLI Info";
|
||||
|
||||
public const string Commands = "Commands";
|
||||
|
||||
public const string NewDefinition = "Initialize a basic .NET project";
|
||||
|
||||
public const string RestoreDefinition = "Restore dependencies specified in the.NET project";
|
||||
|
||||
public const string BuildDefinition = "Builds a .NET project";
|
||||
|
||||
public const string PublishDefinition = "Publishes a .NET project for deployment (including the runtime)";
|
||||
|
||||
public const string RunDefinition = "Compiles and immediately executes a.NET project";
|
||||
|
||||
public const string TestDefinition = "Runs unit tests using the test runner specified in the project";
|
||||
|
||||
public const string PackDefinition = "Creates a NuGet package";
|
||||
|
||||
public const string MigrateDefinition = "Migrates a project.json based project to a msbuild based project";
|
||||
|
||||
public const string ProjectModificationCommands = "Project modification commands";
|
||||
|
||||
public const string AddDefinition = "Add items to the project";
|
||||
|
||||
public const string RemoveDefinition = "Remove items from the project";
|
||||
|
||||
public const string AdvancedCommands = "Advanced Commands";
|
||||
|
||||
public const string NugetDefinition = "Provides additional NuGet commands";
|
||||
|
||||
public const string MsBuildDefinition = "msbuilds a project and all of its dependencies";
|
||||
|
||||
public const string VsTestDefinition = "Runs tests from the specified files";
|
||||
}
|
||||
}
|
|
@ -59,10 +59,6 @@ namespace Microsoft.DotNet.Tools.Migrate
|
|||
var projectsToMigrate = GetProjectsToMigrate(_projectArg);
|
||||
|
||||
var msBuildTemplatePath = _templateFile ?? temporaryDotnetNewProject.MSBuildProjectPath;
|
||||
|
||||
var sdkVersion = _sdkVersion ?? temporaryDotnetNewProject.MSBuildProject.GetSdkVersion();
|
||||
|
||||
EnsureNotNull(sdkVersion, "Null Sdk Version");
|
||||
|
||||
MigrationReport migrationReport = null;
|
||||
|
||||
|
@ -73,7 +69,6 @@ namespace Microsoft.DotNet.Tools.Migrate
|
|||
var migrationSettings = new MigrationSettings(
|
||||
projectDirectory,
|
||||
outputDirectory,
|
||||
sdkVersion,
|
||||
msBuildTemplatePath,
|
||||
_xprojFilePath);
|
||||
var projectMigrationReport = new ProjectMigrator().Migrate(migrationSettings, _skipProjectReferences);
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Microsoft.DotNet.Tools.MSBuild
|
|||
|
||||
private const string MSBuildExeName = "MSBuild.dll";
|
||||
|
||||
private const string ExtensionsDirectoryName = "Extensions";
|
||||
private const string SdksDirectoryName = "Sdks";
|
||||
|
||||
private readonly ForwardingApp _forwardingApp;
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace Microsoft.DotNet.Tools.MSBuild
|
|||
|
||||
return Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
ExtensionsDirectoryName);
|
||||
SdksDirectoryName);
|
||||
}
|
||||
|
||||
private static string GetRunCscPath()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
|
@ -12,14 +11,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.App">
|
||||
<Version>1.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161104-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard1.4</TargetFramework>
|
||||
|
@ -11,14 +10,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NETStandard.Library">
|
||||
<Version>1.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161104-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NETStandard.Library" Version="1.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
|
@ -12,23 +11,10 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.App">
|
||||
<Version>1.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161104-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk">
|
||||
<Version>15.0.0-preview-20161123-03</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MSTest.TestAdapter">
|
||||
<Version>1.1.5-preview</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MSTest.TestFramework">
|
||||
<Version>1.0.6-preview</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20161123-03" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.1.5-preview" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.0.6-preview" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
|
@ -12,23 +11,10 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.App">
|
||||
<Version>1.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161104-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk">
|
||||
<Version>15.0.0-preview-20161123-03</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit">
|
||||
<Version>2.2.0-beta4-build3444</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<Version>2.2.0-beta4-build1194</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20161123-03" />
|
||||
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta4-build1194" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
25
src/dotnet/commands/dotnet-remove/LocalizableStrings.cs
Normal file
25
src/dotnet/commands/dotnet-remove/LocalizableStrings.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
namespace Microsoft.DotNet.Tools.Remove
|
||||
{
|
||||
internal class LocalizableStrings
|
||||
{
|
||||
public const string NetRemoveCommand = ".NET Remove Command";
|
||||
|
||||
public const string Usage = "Usage";
|
||||
|
||||
public const string Options = "Options";
|
||||
|
||||
public const string HelpDefinition = "Show help information";
|
||||
|
||||
public const string Arguments = "Arguments";
|
||||
|
||||
public const string ArgumentsObjectDefinition = "The object of the operation. If a project file is not specified, it defaults to the current directory.";
|
||||
|
||||
public const string ArgumentsCommandDefinition = "Command to be executed on <object>.";
|
||||
|
||||
public const string ArgsDefinition = "Any extra arguments passed to the command. Use `dotnet add <command> --help` to get help about these arguments.";
|
||||
|
||||
public const string Commands = "Commands";
|
||||
|
||||
public const string CommandP2PDefinition = "Remove project to project (p2p) reference from a project";
|
||||
}
|
||||
}
|
|
@ -16,22 +16,22 @@ namespace Microsoft.DotNet.Tools.Remove
|
|||
{
|
||||
public class RemoveCommand : DispatchCommand
|
||||
{
|
||||
protected override string HelpText => @".NET Remove Command;
|
||||
protected override string HelpText => $@"{LocalizableStrings.NetRemoveCommand};
|
||||
|
||||
Usage: dotnet remove [options] <object> <command> [[--] <arg>...]]
|
||||
{LocalizableStrings.Usage}: dotnet remove [options] <object> <command> [[--] <arg>...]]
|
||||
|
||||
Options:
|
||||
-h|--help Show help information
|
||||
{LocalizableStrings.Options}:
|
||||
-h|--help {LocalizableStrings.HelpDefinition}
|
||||
|
||||
Arguments:
|
||||
<object> The object of the operation. If a project file is not specified, it defaults to the current directory.
|
||||
<command> Command to be executed on <object>.
|
||||
{LocalizableStrings.Arguments}:
|
||||
<object> {LocalizableStrings.ArgumentsObjectDefinition}
|
||||
<command> {LocalizableStrings.ArgumentsCommandDefinition}
|
||||
|
||||
Args:
|
||||
Any extra arguments passed to the command. Use `dotnet add <command> --help` to get help about these arguments.
|
||||
{LocalizableStrings.ArgsDefinition}
|
||||
|
||||
Commands:
|
||||
p2p Remove project to project (p2p) reference from a project";
|
||||
{LocalizableStrings.Commands}:
|
||||
p2p {LocalizableStrings.CommandP2PDefinition}";
|
||||
|
||||
protected override Dictionary<string, Func<string[], int>> BuiltInCommands => new Dictionary<string, Func<string[], int>>
|
||||
{
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
namespace Microsoft.DotNet.Tools.Remove.ProjectToProjectReference
|
||||
{
|
||||
internal class LocalizableStrings
|
||||
{
|
||||
/// del p2p
|
||||
public const string ReferenceNotFoundInTheProject = "Specified reference {0} does not exist in project {1}.";
|
||||
|
||||
public const string ReferenceRemoved = "Reference `{0}` deleted from the project.";
|
||||
|
||||
public const string SpecifyAtLeastOneReferenceToRemove = "You must specify at least one reference to delete. Please run dotnet delete --help for more information.";
|
||||
|
||||
public const string ReferenceDeleted = "Reference `{0}` deleted.";
|
||||
|
||||
public const string SpecifyAtLeastOneReferenceToDelete = "You must specify at least one reference to delete. Please run dotnet delete --help for more information.";
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectToProjectReference
|
|||
app.OnExecute(() => {
|
||||
if (string.IsNullOrEmpty(projectArgument.Value))
|
||||
{
|
||||
throw new GracefulException(LocalizableStrings.RequiredArgumentNotPassed, "<Project>");
|
||||
throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, "<Project>");
|
||||
}
|
||||
|
||||
var msbuildProj = MsbuildProject.FromFileOrDirectory(projectArgument.Value);
|
|
@ -27,7 +27,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
var projectDirectoryRelativeFilePaths = EnumerateFilesWithRelativePath(testProjectDirectory);
|
||||
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(testProjectDirectory, outputDirectory, "1.0.0", mockProj);
|
||||
var testSettings = new MigrationSettings(testProjectDirectory, outputDirectory, mockProj);
|
||||
|
||||
var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule());
|
||||
projectMigrator.Migrate(testSettings);
|
||||
|
@ -46,7 +46,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
.Path;
|
||||
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, "1.0.0", mockProj);
|
||||
var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, mockProj);
|
||||
|
||||
var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule());
|
||||
var report = projectMigrator.Migrate(testSettings);
|
||||
|
@ -67,7 +67,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
.Path;
|
||||
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, "1.0.0", mockProj);
|
||||
var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, mockProj);
|
||||
|
||||
var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule());
|
||||
var report = projectMigrator.Migrate(testSettings);
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
private JObject _projectJson;
|
||||
|
||||
private bool _baseDefined = false;
|
||||
private bool _baseProjectDirectory;
|
||||
|
||||
public ProjectJsonBuilder(TestAssetsManager testAssetsManager)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
var projectContext =
|
||||
ProjectContext.Create(projectDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
_mockProject = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(projectDirectory, projectDirectory, "1.0.0", _mockProject, null);
|
||||
var testSettings = new MigrationSettings(projectDirectory, projectDirectory, _mockProject, null);
|
||||
var testInputs = new MigrationRuleInputs(
|
||||
new[] {projectContext},
|
||||
_mockProject,
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
var testProjectDirectory = TestAssetsManager.CreateTestInstance("TestAppWithRuntimeOptions").Path;
|
||||
var projectContext = ProjectContext.Create(testProjectDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
|
||||
var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, "1.0.0", templateProj);
|
||||
var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, templateProj);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, templateProj, templateProj.AddItemGroup(),
|
||||
templateProj.AddPropertyGroup());
|
||||
new MigrateBuildOptionsRule().Apply(testSettings, testInputs);
|
||||
|
|
|
@ -49,31 +49,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
privateAssetsMetadata.Value.Should().Be("All");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_migrates_web_projects_to_have_web_sdk_PrivateAssets()
|
||||
{
|
||||
var mockProj = RunPackageDependenciesRuleOnPj(@"
|
||||
{
|
||||
""buildOptions"": {
|
||||
""emitEntryPoint"": true
|
||||
},
|
||||
""dependencies"": {
|
||||
""Microsoft.AspNetCore.Mvc"" : {
|
||||
""version"": ""1.0.0""
|
||||
}
|
||||
},
|
||||
""frameworks"": {
|
||||
""netcoreapp1.0"": {}
|
||||
}
|
||||
}");
|
||||
|
||||
var packageRef = mockProj.Items.FirstOrDefault(i =>
|
||||
i.Include == "Microsoft.NET.Sdk.Web" && i.ItemType == "PackageReference");
|
||||
|
||||
packageRef.Should().NotBeNull();
|
||||
packageRef.GetMetadataWithName("PrivateAssets").Value.Should().NotBeNull().And.Be("All");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_migrates_suppress_parent_array_to_PrivateAssets()
|
||||
{
|
||||
|
@ -431,7 +406,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
i => (i.Include == "NETStandard.Library" && i.ItemType == "PackageReference"));
|
||||
}
|
||||
|
||||
private void EmitsPackageReferences(ProjectRootElement mockProj, params Tuple<string, string, string>[] packageSpecs)
|
||||
new private void EmitsPackageReferences(ProjectRootElement mockProj, params Tuple<string, string, string>[] packageSpecs)
|
||||
{
|
||||
foreach (var packageSpec in packageSpecs)
|
||||
{
|
||||
|
@ -449,7 +424,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
}
|
||||
}
|
||||
|
||||
private void EmitsToolReferences(ProjectRootElement mockProj, params Tuple<string, string>[] toolSpecs)
|
||||
new private void EmitsToolReferences(ProjectRootElement mockProj, params Tuple<string, string>[] toolSpecs)
|
||||
{
|
||||
foreach (var toolSpec in toolSpecs)
|
||||
{
|
||||
|
@ -465,7 +440,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
}
|
||||
}
|
||||
|
||||
private ProjectRootElement RunPackageDependenciesRuleOnPj(string s, string testDirectory = null)
|
||||
new private ProjectRootElement RunPackageDependenciesRuleOnPj(string s, string testDirectory = null)
|
||||
{
|
||||
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
|
||||
return TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj, null);
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, mockProj, null);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
|
||||
mockProj.AddPropertyGroup());
|
||||
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
|
||||
|
@ -51,7 +51,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj, null);
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, mockProj, null);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
|
||||
mockProj.AddPropertyGroup());
|
||||
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
|
||||
|
@ -71,7 +71,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj, null);
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, mockProj, null);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
|
||||
mockProj.AddPropertyGroup());
|
||||
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
|
||||
|
@ -97,7 +97,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj);
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, mockProj);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(), mockProj.AddPropertyGroup());
|
||||
|
||||
Action action = () => new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
|
||||
|
@ -260,7 +260,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.Net451);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj, null);
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, mockProj, null);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
|
||||
mockProj.AddPropertyGroup());
|
||||
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
|
||||
|
@ -338,7 +338,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
var projectContext = ProjectContext.Create(appDirectory, targetFramework);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj, null);
|
||||
var testSettings = new MigrationSettings(appDirectory, appDirectory, mockProj, null);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
|
||||
mockProj.AddPropertyGroup());
|
||||
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
var projectContext = ProjectContext.Create(projectDir, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
|
||||
var testSettings = new MigrationSettings(projectDir, projectDir, "1.0.0", default(ProjectRootElement));
|
||||
var testSettings = new MigrationSettings(projectDir, projectDir, default(ProjectRootElement));
|
||||
var testInputs = new MigrationRuleInputs(new[] { projectContext }, null, null, null);
|
||||
new MigrateRuntimeOptionsRule().Apply(testSettings, testInputs);
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
var projectContext = ProjectContext.Create(projectDir, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
|
||||
var testSettings = new MigrationSettings(projectDir, projectDir, "1.0.0", default(ProjectRootElement));
|
||||
var testSettings = new MigrationSettings(projectDir, projectDir, default(ProjectRootElement));
|
||||
var testInputs = new MigrationRuleInputs(new[] { projectContext }, null, null, null);
|
||||
new MigrateRuntimeOptionsRule().Apply(testSettings, testInputs);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
var projectContext = ProjectContext.Create(testDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
|
||||
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", mockProj);
|
||||
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, mockProj);
|
||||
var migrationInputs = new MigrationRuleInputs(
|
||||
new[] { projectContext },
|
||||
mockProj,
|
||||
|
@ -54,7 +54,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
var projectContexts = ProjectContext.CreateContextForEachFramework(testDirectory);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
|
||||
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", mockProj);
|
||||
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, mockProj);
|
||||
var migrationInputs = new MigrationRuleInputs(
|
||||
projectContexts,
|
||||
mockProj,
|
||||
|
@ -79,7 +79,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
var projectContexts = ProjectContext.CreateContextForEachFramework(testDirectory);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
|
||||
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", mockProj);
|
||||
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, mockProj);
|
||||
var migrationInputs = new MigrationRuleInputs(
|
||||
projectContexts,
|
||||
mockProj,
|
||||
|
@ -109,7 +109,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
var mockProj = ProjectRootElement.Create();
|
||||
|
||||
// Run BuildOptionsRule
|
||||
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", mockProj);
|
||||
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, mockProj);
|
||||
var migrationInputs = new MigrationRuleInputs(
|
||||
projectContexts,
|
||||
mockProj,
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Microsoft.Build.Construction;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.ProjectJsonMigration;
|
||||
using Microsoft.DotNet.ProjectJsonMigration.Rules;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||
{
|
||||
public class GivenThatIWantToMigrateWebProjects : PackageDependenciesTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ItMigratesWebProjectsToHaveWebSdkInTheSdkAttribute()
|
||||
{
|
||||
var csprojFilePath = RunMigrateWebSdkRuleOnPj(@"
|
||||
{
|
||||
""buildOptions"": {
|
||||
""emitEntryPoint"": true
|
||||
},
|
||||
""dependencies"": {
|
||||
""Microsoft.AspNetCore.Mvc"" : {
|
||||
""version"": ""1.0.0""
|
||||
}
|
||||
},
|
||||
""frameworks"": {
|
||||
""netcoreapp1.0"": {}
|
||||
}
|
||||
}");
|
||||
|
||||
File.ReadAllText(csprojFilePath).Should().Contain(@"Sdk=""Microsoft.NET.Sdk.Web""");
|
||||
}
|
||||
|
||||
private string RunMigrateWebSdkRuleOnPj(string s, string testDirectory = null)
|
||||
{
|
||||
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
|
||||
var csprojFilePath = Path.Combine(testDirectory, $"{GetContainingFolderName(testDirectory)}.csproj");
|
||||
|
||||
File.WriteAllText(csprojFilePath, @"
|
||||
<Project Sdk=""Microsoft.NET.Sdk"" ToolsVersion=""15.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
|
||||
<PropertyGroup />
|
||||
<ItemGroup />
|
||||
</Project>");
|
||||
|
||||
TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
|
||||
{
|
||||
new MigrateWebSdkRule()
|
||||
}, s, testDirectory);
|
||||
|
||||
return csprojFilePath;
|
||||
}
|
||||
|
||||
private static string GetContainingFolderName(string projectDirectory)
|
||||
{
|
||||
projectDirectory = projectDirectory.TrimEnd(new char[] { '/', '\\' });
|
||||
return Path.GetFileName(projectDirectory);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
ProjectContext projectContext, string testDirectory, ProjectRootElement xproj)
|
||||
{
|
||||
var project = ProjectRootElement.Create();
|
||||
var testSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", project);
|
||||
var testSettings = new MigrationSettings(testDirectory, testDirectory, project);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, project,
|
||||
project.AddItemGroup(),
|
||||
project.AddPropertyGroup(),
|
||||
|
|
|
@ -180,7 +180,16 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
if (tasksToAwait.Any())
|
||||
{
|
||||
Task.WaitAll(tasksToAwait.ToArray());
|
||||
try
|
||||
{
|
||||
Task.WaitAll(tasksToAwait.ToArray());
|
||||
}
|
||||
catch (System.ObjectDisposedException e)
|
||||
{
|
||||
taskErr = null;
|
||||
|
||||
taskOut = null;
|
||||
}
|
||||
}
|
||||
|
||||
var result = new CommandResult(
|
||||
|
@ -244,7 +253,16 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
if (tasksToAwait.Any())
|
||||
{
|
||||
Task.WaitAll(tasksToAwait.ToArray());
|
||||
try
|
||||
{
|
||||
Task.WaitAll(tasksToAwait.ToArray());
|
||||
}
|
||||
catch (System.ObjectDisposedException e)
|
||||
{
|
||||
taskErr = null;
|
||||
|
||||
taskOut = null;
|
||||
}
|
||||
}
|
||||
|
||||
var result = new CommandResult(
|
||||
|
|
|
@ -14,8 +14,6 @@ namespace Microsoft.DotNet.Tools.Pack.Tests
|
|||
{
|
||||
public class PackTests : TestBase
|
||||
{
|
||||
private readonly string _testProjectsRoot;
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/4488")]
|
||||
public void OutputsPackagesToConfigurationSubdirWhenOutputParameterIsNotPassed()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue