-
Notifications
You must be signed in to change notification settings - Fork 1.1k
VS2017 RC - The target “GetCopyToPublishDirectoryItems” does not exist in the project. #543
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
Comments
From @discostu105 on November 23, 2016 19:52 I have exactly the same problem. btw, "GetCopyToPublishDirectoryItems" is defined over there: https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Publish.targets Maybe @eerhardt knows something about that? Is there a workaround? I'm trying to port my project to .csproj, but this blocks me. |
From @duracellko on December 2, 2016 10:21 I tried workaround to add empty target to referenced class library project: I tried to find a workaround by overriding some targets. After few hours I gave up and I converted project to standard .NET Framework Console Application.
If you use different configuration in development environment, I added command line argument for debug project -AspNetCore:Environment=Development, then in Program.Main method I transformed this command line arguments to environment variable ASPNETCORE_ENVIRONMENT. If you use User Secrets, then add into .csproj file element |
From @duracellko on December 2, 2016 11:2 And I forgot to set Copy to Output Directory for files web.config and appsettings.json. My project is just WebAPI, so no .cshtml file. So it's easy. |
From @hybridview on December 20, 2016 16:33 This issue doesn't appear to have gotten any attention yet. Does anymore know why it happens? I'm trying to find a workaround without having to hack up my project file. |
From @jsgoupil on December 20, 2016 16:55 @hybridview Rolling back to WebAPI2 was the best solution I have done so far. |
From @eerhardt on December 20, 2016 21:39 Sorry, I've been on vacation and haven't been checking email or GitHub. I just saw this now. The problem is that one project uses the new Microsoft.NET.Sdk project system and the referenced class library project doesn't use the same project system. As a workaround, I can think of the following options:
@srivatsn - Is it a supported scenario to mix and match these different project systems across P2P references? |
From @davkean on December 20, 2016 21:47 Yes this is supported. Either we dummy out GetCopyToPublishDirectoryItems or sniff that the target doesn't exist (not sure this is even possible)? |
Yes referencing an existing project from a new one is supported. |
From @coonmoo on December 20, 2016 22:32 I have the same problem with Service Fabric, Asp.Net Core and VS 2017 RC2. To replicate:
I'd love to see a fix for this, because VS 2017 is awesome.
|
From @dsplaisted on December 21, 2016 1:27 @srivatsn We should move this issue to the dotnet/sdk repo. I don't think we currently have tests that cover building an SDK project which references a non-SDK project, much less publishing in this scenario. |
From @EuroForm on December 21, 2016 10:43 Having same problem. Would also love to see a fix to this 😅🙏🔥 |
I've got this problem in a .NET Framework 4.6.2 MVC project using "older class libraries" when using VS2017 RC. The website builds and run locally without any problems, but I'm unable to publish the website. It's difficult for me to know exactly what makes the "older class libraries" work or not, since all my internal project references are having this issue in the solution. Thanks for accepting the issue and looking into it 👍 Looking very much forward to a solution asap 😊 |
What's the status on this issue? I am unable to publish my ASP.NET Core MVC application due to this. The workaround posted by @srivatsn does eliminate the "GetCopyToPublishDirectoryItems" error message but the web application fails at runtime, complaining about missing references "Can not find reference assembly '.NETFramework/v4.6.2/Microsoft.CSharp.dll' file for package microsoft.csharp". I'm sure this is caused by the lack of "refs" folder. |
I have this issue too - can't publish, and now that the Web API project has been converted to .csproj, VS2015 can't load the project, so I can't go back to an older version of VS to publish it either. I'd rather not rollback the code changes I made since the upgrade... any workarounds would be appreciated also. |
Really looking for a fix too, make VS2017 RC2 quite unusable for several kind of projects ! Not easy for .net core projects to get back to VS 2015 when the 2017 is so much better :) |
I have this issue too. This made the problem go away, and the publish process continues much longer. Error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). They must have the same number of items. |
I installed Build 26020.00, but still same issue |
This is a really critical issue and should be really basic. Just have a dotnetcore web project that is including a class library. As people have said, building and running locally works fine, but publishing up to Azure gives the failure messages already mentioned. This "really" sucks as spent a lot of time moving to VS 2017 and things have been pretty decent up until this bug bit me in the ass - at "build" time of all things. Really frustrating as got everything else to work and build. |
Really looking for a fix too. I experience the same issue and unable to publish after upgrade. |
We haven't forgotten about this issue, and we're aware of the pain. We're trying to figure out the best approach to take for this. |
For starters, here is a more complete workaround using a default target that makes non Microsoft.NET.Sdk-based projects respect the default publish semantics. Add the following to a new or existing Directory.Build.targets somewhere that is above all of the projects in the solution (e.g.. repository root directory). MSBuild will then pick up the targets for any project underneath that directory: <Project>
<!--
Work around https://github.com/dotnet/sdk/issues/543 with a default implementation of
GetCopyToPublishDirectoryItems that simply returns whatever GetCopyToOutputDirectoryItems
does with CopyToPublishDirectory implied by CopyToOutputDirectory, which is the same as
Microsoft.NET.Sdk default when CopyToPublishDirectory is not used. Microsoft.NET.Sdk projects
will override this to allow the publish output to be customized independently from the build output.
-->
<Target
Name="GetCopyToPublishDirectoryItems"
DependsOnTargets="GetCopyToOutputDirectoryItems"
Returns="@(AllPublishItemsFullPathWithTargetPath)">
<ItemGroup>
<AllPublishItemsFullPathWithTargetPath Include="@(AllItemsFullPathWithTargetPath)">
<CopyToPublishDirectory>%(CopyToOutputDirectory)</CopyToPublishDirectory>
</AllPublishItemsFullPathWithTargetPath>
</ItemGroup>
</Target>
</Project> |
@cceuroform That looks like a separate issue that was fixed by #581 |
@cceuroform Can you do |
@nguerrera you're totally speaking greek to me. I just want to be able to do a basic publish to and Azure Website and not sure how specific and granular the publishing controls are to Azure. |
The idea is that if you create the Directory.Build.targets file @nguerrera describes in your source code, then it will be used during the publish process, potentially restoring your ability to publish to Azure. |
@nguerrera The file is huge. 116 MBytes. How can I share it with you? |
@cceuroform Can you locate where the |
@nguerrera msbuild.log |
@nguerrera Did you verify it is #581?. Any workaround? |
Pasting the relevant part here for others to see easily:
cc @eerhardt @dsplaisted : This actually looks a little different -- there's a conflict with ImplicitlyExpandDesignTimeFacades and a package providing a newer System.IO facade. Applying the two-line change from https://github.com/dotnet/sdk/pull/581/files#diff-ffd1a974928a37a20fbc471c040962ac (fix from #581) to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Publish.targets might get it past this point, but it might also hide the root cause and deploy the older ref, which might cause Razor some problems. @dsplaisted I think you mentioned looking at conflicts with implicit facades somewhere. Thoughts on this? |
@nguerrera I will try to apply the two-line change from #581 |
This supports the publish scenario of Microsoft.NET.Sdk-based projects that reference non-Microsoft.NET.Sdk-based projects. Fix dotnet/sdk#543
@nguerrera After apply the change from #581, the previous error disapeared. :) C:\Data\EF\Repo\Projects\EF.Definition\EF.Definition.csproj : error MSB4057: The target "GetCopyToPublishDirectoryItems" does not exist in the project. Here is the csproj file EF.Definition.csproj I was able to fix that to after inserting < Target Name="GetCopyToPublishDirectoryItems" / > Now I was able to build a deploy for that little toy-app. After that I inserted the same line to all our projects (~450 csprojects), and I am now able to deploy out app to IIS on a Azure VM. :) We still need to do some testing, but for now it seems to work for our part at least. |
@nguerrera I am accessing a portable class library in .net core app(CrossPlatformWebApp). solution can be accessed at i am getting below error when i try to publish to file system - 2017\Projects\CrossPlatformDevelopment\CrossPlatformWebApp\bin\Debug\netcoreapp1.0\CrossPlatformWebApp.dll |
@ankgupta067 Try to add < Target Name="GetCopyToPublishDirectoryItems" / > in every csproj file that fails with the error. That was helping in my case. |
@ankgupta067 You named the file "build.targets", but it needs to be named "Directory.build.targets" to be picked up by msbuild. Try that. @cceuroform That would get past the error, but can also cause required files to be missing from the publish directory. The target should match #543 (comment). You could put that in every project, but using Directory.build.targets makes it easier to apply to all projects and also easier to revert once the real fix lands. |
@nguerrera works perfectly thanks |
The fix for this has been checked into MSBuild - dotnet/msbuild#1544 |
Thanks for working on the problem ... seems there is a clear solution now, how does the public get there hands on an update? |
From @delie on November 18, 2016 23:17
After installing Visual Studio 2017 RC, and upgrading my ASP.NET Core Web Application (.NET Framework) project to CSPROJ, I am no longer able to publish my project to the file system. Building the solution works fine, but when I publish I get this error:
To replicate:
Copied from original issue: aspnet/Tooling#869
The text was updated successfully, but these errors were encountered: