Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

dnu pack fails when project.json is readonly. #1612

Closed
phenning opened this issue Apr 7, 2015 · 21 comments · Fixed by #1850
Closed

dnu pack fails when project.json is readonly. #1612

phenning opened this issue Apr 7, 2015 · 21 comments · Fixed by #1850
Assignees
Milestone

Comments

@phenning
Copy link

phenning commented Apr 7, 2015

When running dnu pack on a project where the project.json is a read-only file, the following exception and callstack is generated. This impacts SCC (TFS) scenarios where the project.json is not checked out.

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : System.UnauthorizedAccessException: Access to the path 'c:\users\phenning\documents\visual studio 2015\Projects\artifacts\bin\ConsoleApp6\Debug\app\project.json' is denied.

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at System.IO.File.WriteAllText(String path, String contents)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at Microsoft.Framework.PackageManager.InstallBuilder.ModifyJson(String jsonFile, Action`1 modifier)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at Microsoft.Framework.PackageManager.InstallBuilder.WriteApplicationProjectJsonFile(String applicationFolder)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at Microsoft.Framework.PackageManager.InstallBuilder.BuildApplicationFiles(String baseOutputPath)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at Microsoft.Framework.PackageManager.InstallBuilder.Build(String outputPath)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at Microsoft.Framework.PackageManager.BuildManager.Build()

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at Microsoft.Framework.PackageManager.Program.<>c__DisplayClass3_3.<Main>b__6()

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute(String[] args)

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(134,5): error : at Microsoft.Framework.PackageManager.Program.Main(String[] args)
@davidfowl
Copy link
Member

/cc @muratg @victorhurdugaci

@victorhurdugaci Why is the InstallBuilder doing anything with the project.json here?

@muratg muratg added this to the 1.0.0-beta5 milestone Apr 8, 2015
@muratg
Copy link
Contributor

muratg commented May 12, 2015

@victorhurdugaci , can you have a look?

@davidfowl
Copy link
Member

This is a simple fix. a One liner actually.

@davidfowl
Copy link
Member

I can fix it if @victorhurdugaci is working on something else. I'd suggest waiting on @troydai's change though.

@victorhurdugaci
Copy link
Contributor

I can fix it too, I have time for this :)

@davidfowl
Copy link
Member

Great!

@davidfowl
Copy link
Member

using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))

File.OpenRead should fix it.

@davidfowl
Copy link
Member

That file moved into the package manager and there should be a new one from @troydai 's change in the runtime

@Darkonekt
Copy link

Hi, I am getting the exact same error and stack trace. My problem is trying to run an automated build on a TFS build agent. It copies the file to ...\Release\app\project.json and sets it to read-only. After that the build fails with the same stack trace you are showing at the top of this thread. I have not been able to run a build. TFS 2013 update 4 build controller and agent. Please update.

@victorhurdugaci
Copy link
Contributor

@Darkonekt , what DNX version do you use?

@Darkonekt
Copy link

when I look in the .dnx folder for my user I see 1.0.0-beta-4 for all four folders under runtime.
I have tried both CORECLR and the the other one 'clr' both X86. If I compile the solution from the BuildAgent using visual studio it works. But the Automated Build fails everytime. In my stack trace I can see the DNX.targets file is from visual studio 2015 because I can see in the path v14.0.

@victorhurdugaci
Copy link
Contributor

Unfortunately, the fix is only in beta5. The only solution is to update to the latest bits. Sorry for the inconvenience.

@Darkonekt
Copy link

How can I do that? I don't see the beta5 available as a nuget. Please advice how to do the update. This is the only thing preventing me from running an automated build. Thank you.

@Darkonekt
Copy link

I am probably abusing your time. But let me know or point me in the right direction on how to update my DNX installation to latest beta. This is very urgent to me.

@BrennanConroy
Copy link
Member

dnvm upgrade -u

@Darkonekt
Copy link

nice thanks I will try it

@Darkonekt
Copy link

ok I upgraded to version using dnvm install and passing "latest". which installed version beta4-11566
I modified the default.txt to use that version. Tried both clr and coreclr as default. but I get the same error message. Is this the latest version where the fix for this is supposed to be?

@victorhurdugaci
Copy link
Contributor

Nope, that didn't bring the latest dev bits. It should be beta5-number.

Did you run dnvm upgrade -u ?

From here:

DNVM has the concept of a stable and unstable feed. Stable defaults to NuGet.org while unstable defaults to our dev MyGet feed. So if you add -u or -unstable to any of the install or upgrade commands you will get our latest CI build of the DNX instead of the one last released on NuGet.

@Darkonekt
Copy link

My dnvm power shell script under C:\Program Files\Microsoft DNX\Dnvm DOES NOT contain a -u or -unstable switch. This is the function function dnvm-upgrade {
param(
[Alias("a")]
[Parameter(Mandatory=$false, Position=0)]
[string]$Alias = "default",

    [Alias("arch")]
    [ValidateSet("", "x86","x64")]
    [Parameter(Mandatory=$false)]
    [string]$Architecture = "",

    [Alias("r")]
    [ValidateSet("", "clr","coreclr")]
    [Parameter(Mandatory=$false)]
    [string]$Runtime = "",

    [Alias("f")]
    [Parameter(Mandatory=$false)]
    [switch]$Force,

    [Parameter(Mandatory=$false)]
    [string]$Proxy,

    [Parameter(Mandatory=$false)]
    [switch]$NoNative,

    [Parameter(Mandatory=$false)]
    [switch]$Ngen)

dnvm-install "latest" -Alias:$Alias -Architecture:$Architecture -Runtime:$Runtime -Force:$Force -Proxy:$Proxy -NoNative:$NoNative -Ngen:$Ngen -Persistent:$true

}

As you can see there is no such switch any ides?

@victorhurdugaci
Copy link
Contributor

Ok, no worries. We can fix that :)

Edit the PATH environment variable and remove C:\Program Files\Microsoft DNX\Dnvm from it. Then, follow the instructions in the Home repo to install Dnvm. You have to run the command below from a command prompt:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}" 

Once you are done with that, you should get a new Dnvm in %userprofile%\.dnx\bin which supports the -u argument

@moozzyk
Copy link
Contributor

moozzyk commented May 19, 2015

I think I had to remove dnvm* from C:\Program Files\Microsoft DNX\Dnvm\ otherwise the script would refuse to overwrite the files and dnvm would not get updated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants