Piotrp msft/merge2msbuild (#3923)

* Add Test for removing readonly flag when copying readonly library assets

* change namespace

* PR Feedback

* Update README.md (#3904)

* Update README.md

* Responding to PR feedback

* Responding to PR feedback
This commit is contained in:
Piotr Puszkiewicz 2016-07-23 13:38:31 -04:00 committed by GitHub
parent fd8bbdcb63
commit fe5119fde4
3 changed files with 81 additions and 2 deletions

View file

@ -11,6 +11,17 @@ check out our [Getting started page](http://go.microsoft.com/fwlink/?LinkID=7983
Also, don't forget to check out [the documentation](https://aka.ms/dotnet-cli-docs). Also, don't forget to check out [the documentation](https://aka.ms/dotnet-cli-docs).
Changes in issue triaging
-------------------------
We are making significant changes to the CLI tooling by supporting MSBuild as the build engine and `csproj` as the project format. You can read ["Changes to project.json" blog post](https://blogs.msdn.microsoft.com/dotnet/2016/05/23/changes-to-project-json/) for more context. We've realized that this also means that many of the shortcomings of the current tooling will be solved by this move so we've decided to introduce two new labels to indicate that in the issues:
* `msbuild-mitigated` - this label indicates the issue will be mitigated via move to MSBuild.
* `msbuild-notapplicable` - this label indicates the issue will not be applicable after moving to MSBuild.
We will close issues that are labelled with one of these labels. Proactive triaging will help us reduce the number of issues and enable us to focus on issues that require fixing independent of the move to msbuild.
Please feel free to re-open and comment on any issue that you believe was triaged incorrectly.
Found an issue? Found an issue?
--------------- ---------------
You can consult the [known issues page](https://github.com/dotnet/core/blob/master/cli/known-issues.md) to find out the current issues and You can consult the [known issues page](https://github.com/dotnet/core/blob/master/cli/known-issues.md) to find out the current issues and

View file

@ -5,9 +5,9 @@ using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit; using Xunit;
namespace Microsoft.DotNet.Cli.Compiler.Common namespace Microsoft.DotNet.Cli.Compiler.Common.Tests
{ {
public class Tests : TestBase public class GivenCommonCompilerOptions : TestBase
{ {
[Fact] [Fact]
public void SimpleSerialize() public void SimpleSerialize()

View file

@ -0,0 +1,68 @@
// 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 FluentAssertions;
using Xunit;
using Microsoft.DotNet.Cli.Compiler.Common;
using Microsoft.DotNet.ProjectModel.Compilation;
using System.IO;
using System;
using System.Linq;
using System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Compiler.Common.Tests
{
public class GivenThatICopyLibraryAssets
{
[Fact]
public void LibraryAsset_CopyTo_Clears_Readonly()
{
var libraryAsset = GetMockLibraryAsset(nameof(LibraryAsset_CopyTo_Clears_Readonly));
MakeFileReadonly(libraryAsset.ResolvedPath);
IEnumerable<LibraryAsset> assets = new LibraryAsset[] { libraryAsset };
var outputDirectory = Path.Combine(AppContext.BaseDirectory,$"{nameof(LibraryAsset_CopyTo_Clears_Readonly)}_out");
assets.CopyTo(outputDirectory);
var copiedFile = Directory.EnumerateFiles(outputDirectory, Path.GetFileName(libraryAsset.RelativePath)).First();
IsFileReadonly(copiedFile).Should().BeFalse();
}
[Fact]
public void LibraryAsset_StructuredCopyTo_Clears_Readonly()
{
var libraryAsset = GetMockLibraryAsset(nameof(LibraryAsset_StructuredCopyTo_Clears_Readonly));
MakeFileReadonly(libraryAsset.ResolvedPath);
IEnumerable<LibraryAsset> assets = new LibraryAsset[] { libraryAsset };
var intermediateDirectory = Path.Combine(AppContext.BaseDirectory,$"{nameof(LibraryAsset_StructuredCopyTo_Clears_Readonly)}_obj");
var outputDirectory = Path.Combine(AppContext.BaseDirectory,$"{nameof(LibraryAsset_StructuredCopyTo_Clears_Readonly)}_out");
assets.StructuredCopyTo(outputDirectory, intermediateDirectory);
var copiedFile = Directory.EnumerateFiles(outputDirectory, Path.GetFileName(libraryAsset.RelativePath)).First();
IsFileReadonly(copiedFile).Should().BeFalse();
}
private void MakeFileReadonly(string file)
{
File.SetAttributes(file, File.GetAttributes(file) | FileAttributes.ReadOnly);
}
private bool IsFileReadonly(string file)
{
return (File.GetAttributes(file) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly;
}
private LibraryAsset GetMockLibraryAsset(string mockedLibraryAssetName)
{
var mockedLibraryAssetFileName = $"{mockedLibraryAssetName}.dll";
var fakeFile = Path.Combine(AppContext.BaseDirectory, mockedLibraryAssetFileName);
File.WriteAllText(fakeFile, mockedLibraryAssetName);
return new LibraryAsset(mockedLibraryAssetName, mockedLibraryAssetFileName, fakeFile);
}
}
}