The target "GatherAllFilesToPublish" does not exist in the project - visual-studio-2017

I've checked that the same error occurred in the past with earlier vs .net versions but I am facing this issue in VS 2017 while trying to upgrade from VS Community 15.3.5 to 15.4.
I first installed using the web installer by choosing the options,
some how there were a couple of errors & the download + installation took over 9+ hours
visual studio was working and compiling project except that this had the problem 'The target "GatherAllFilesToPublish" does not exist in the project'.
Then I tried downloading the entire setup using "vs_community.exe --layout "C:\MyFolder" --lang en-US" which again took over 9 hours to finish download. Re-ran the setup choosing Repair, again the same issue.
Is any one aware of a quicker way to solve this above problem?

I had similar problem and it solved by changing csproj file:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
changed to
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" Condition="true" />

I had same issue (Visual Studio 2017).
Install - " MSBuild.Microsoft.VisualStudio.Web.targets " nuget package to visual studio. And then try to publish.

Just install the ASP.Net Web Deployment component for VS2017, it worked for me.

Similar issue occurred with me after I upgraded project from previous version to VS 2017. I had to make following changes in the csproj file.
Uncomment the following part of code from csproj file ( It was already present as comment, not sure why it did not change while upgrade automatically. If you do not have it, add below lines of code.)
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
</VSToolsPath>
</PropertyGroup>
Make sure below 3 imports are present in the csproj file. (These were also present, but if not, add manually)
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
And then I was able to publish the project.

I wonder what packages are changing these paths?
Mine is as follows:
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildProgramFiles32)\MSBuild\Microsoft\VisualStudio\v14.0</VSToolsPath>
changed to
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
same issue as this: https://stackoverflow.com/a/48545538/231821

I had this same problem, I updated Visual Studio 2017 to a newer version via the installer.
The installer never completed successfully. It completed with some errors which I just ignored so many of the components weren't installed which came after the components with errors. After I resolved the error components, the rest of the installation finally completed successfully and I could publish again with no problems.
I think some of the components which wasn't installed previously was older versions which was not compatible with the new update.
Try installing/updating your visual studio completely with no errors.

Related

Missing file NuGet.targets on existing project

The scenario is:
1. Created a NEW solution
2. ENABLED download missing packages
3. Add projects to solution that already exists and depends on nuget packages
4. Building the solution generates an error:
... The missing file is <solution folder>\.nuget\NuGet.targets.
Why? Have missing something?
I'm using Visual Studio 2017 Pro on Windows 10
All my searches answer about the scenario where create a new solution and adds a new project that depends on nuget package, that's ok, but when have an existing project, nothing.
<solution folder>\.nuget\NuGet.targets is a file that NuGet's Visual Studio extension used to add in Visual Studio 2010, 2012 and 2013 when you right click on the solution and select "Enable NuGet Package Restore". It would then add an import in all of your project files to import the targets file. I was recently investigating a customer issue and as part of that investigation I found it made the following changes. Near the top of the csproj, it adds something like this:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
and near the end of the csproj it adds somthing like this:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
So, the problem is that you're creating a new solution, but using existing project files that have been modified in this way. One option is to edit your csrpoj files and remove these changes. Another option is to create new projects, in addition to the new solution, and then copy all your code and content files.
The only disadvantage is if you build on a CI server and use packages.config, your build script needs to run nuget.exe restore, whereas projects that use NuGet.targets could just build the solution and msbuild would execute nuget restore as needed. One advantage of no longer using NuGet.targets is that restoring the whole solution is faster than restoring project by project. Visual Studio automatically restores packages on build, even in VS2010, VS2012 and VS2013, so personally I discourage the use of using this feature, even if you use those old versions of Visual Studio. The benefit of reducing your build script by one step is not worth the issues it brings, in my opinion.

Visual Studio Team Services build fails because CoreCompile does not reference NuGet assembly

I am running into an weird issue where my build works perfectly on local machine but almost always fails on Visual Studio Team Services build agent. I say almost always the same code sometimes builds fine on VSTS build agent.
The error is that for a project in my solution, the compiler could not find System.Web.Http.dll, which is referenced in Microsoft.AspNet.WebApi.Core NuGet package. I've checked the reference and it is there. I've removed the NuGet and re-added it to fix any potential NuGet hiccup.
The exact error is this:
Error CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
The reference is in the csproj file:
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\Microsoft.AspNet.Cors.5.2.3\lib\net45\System.Web.Cors.dll</HintPath>
</Reference>
The NuGet restore task from VSTS suggested that all NuGet packages were installed, but the build still failed.
I then did a diff between the command lines of the successful build and failed build, both from Visual Studio Team Services build agent and found that the failed build CoreCompile task was missing some assembly references.
CoreCompile gets the assemblies to reference from ResolveAssemblyReferences. But ResolveAssemblyReferences claims that it could not find System.Web.Http.dll.
For SearchPath "{HintPathFromItem}".
Considered "....\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll", but it didn't exist.
Is there any known issue with NuGet restore from VSO? We are using NuGet 4.0.
UPDATE:
Visual Studio Team Services support came back to me. I had my own nuget.config which had the following 2 lines. This interfered with the global NuGet cache on the build agents. Once I removed these 2 lines everything went smoothly as expected.
<add key="globalPackagesFolder" value="..\nupkgs" />
<add key="PackageSaveMode" value="nuspec" />
It looks like, at some point, this reference was added manually, and the relative paths match up on your local PC.
In every valid nuget reference I've seen, those relative paths are prefixed with "packages". Try deleting the nuget package, and delete this reference, then reinstall it.
Here is the answer to the issue I ran into.
Visual Studio Team Services support came back to me. I had my own nuget.config which had the following 2 lines. This interfered with the global NuGet cache on build agents. Once I removed these 2 lines everything went smoothly as expected.
<add key="globalPackagesFolder" value="..\nupkgs" />
<add key="PackageSaveMode" value="nuspec" />

NuGet packages not restore in visual studio 2017

I have Asp.netCore solution which was working fine on Visual Studio 2015 and then i moved to Visual Studio 2017. Now the problem is that in Visual Studio 2017 on every nuget packages there is yellow exclamation mark. Following are solution which i have tried so far.
I'm using Visual Studio Version: 15.3.1
Run as 'Administrator' and restore package.
Clear All Nugget Cache(s) from Tools > options > NuGet Package Manager > and again restore Nuget.
Note: I have searched and found following solution and tried but did not resolve my issue.
Solution 1
I found the answer on another thread here and credit should go to #AxelWass although he did not specifically focus it towards this, it absolutely fixes this issue. The above answer did not.
I had the same issue and solve it by opening the project in a text editor and deleting the following section:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
Once this is removed, it will resolve this nightmare issue that VS2017 and PM seems to be unable to resolve. I too have run into this multiple times - especially when I blend many projects in the same solutions directory.
As mentioned in Microsoft Installing and reinstalling packages with package restore Documentation, you should Update-Package -reinstall:
Update-Package -reinstall -ProjectName <project> command where
is the name of the affected project as it appears in
Solution Explorer. Use Update-Package -reinstall by itself to restore
all packages in the solution.
If you still have the error, try edit your project file, check if there is A path refrence error there, also check the project/solution nuget config file.
By default, new installation of visual studio did not configure package source to search packages online. That caused the problem.
I found the answer with a little bit more work from a stackoverflow link: https://stackoverflow.com/a/32360953/1503372.
That answer mentions to use "https://www.nuget.org/api/v2" url to restore packages. When I opened the package manager console in visual studio 2017, I found it was searching for packages from my PC only (offline search).
I then added "https://www.nuget.org/api/v2" url as a source for restoring packages and it worked.
Follow below steps to add a package source.
Right click project > Manage nuget package and you will see "package source label".
Add highlighted URL to package source.
Select "All" as package source.
Once you have configured your visual studio to search for packages online, your all packages will be restored.
I discovered a wrong configuration in the nuget.config. I don't know why, in this file there are some exclusion for my current project.
You can see your global configuration running this command in File Explorer
%AppData%\NuGet\NuGet.Config

Visual Studio 15 Compilation Fails- clean project

I am using Visual Studio 15 Preview 3
When I create a new project (ASP.Net 5 "Empty" project) and press build all it fails to build. I get the following errors.
Severity Code Description Project File Line Suppression State
Error MSB4063 The "VsTsc" task could not be initialized with its input parameters. WebApplication3 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets 247
Error MSB4064 The "OutputLogFile" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property. WebApplication3 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets 261
Any suggestions please. I have added no code, just created the project and pressed build.
If you check out the Output window contents after the build has failed, it should show the targets file path like this one:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets
Go ahead and remove the OutputLogFile attribute from the VsTsc element. This should make the build go through.
Downgrading "Microsoft.TypeScript.MSBuild" from version 2.0.6 to 1.8.11 removed the Compilation Errors.
I had a similar issue. As it turns out the VsTsc task does support OutputLogFile. When I installed the newer TypeScript nuget packages (Microsoft.TypeScript.Compiler and Microsoft.TypeScript.MSBuild) then it adds Microsoft.TypeScript.targets to the .csproj but neglects to remove the previous lines. Nuget will add lines similar to
<Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.props" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.props')" />
<Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.targets" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.targets')" />
You have to manually removed the two lines pointing to :
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
The same errors were observed after installing Visual Studio Preview. Visual Studio 2015 Community addition Update 3 installed on the same computer also started getting the same errors, on a number of different Typescript solutions. I could build the same solutions on an old computer 'Visual Studio 2015 Community addition Update 1'. I then uninstall Visual Studio Preview. Errors still occurred on Visual Studio 2015 Community addition Update 3. Also then uninstalled and reinstalled community addition and the problem was resolved, and could build the project. I thought this solution may help others with the problem solving a more elegant solution I do not have the reputation points to make a comment (where this belongs).
I was having the same issue with VS2015 Community and downloading the latest version of TypeScript (Version 2.1.5 posted 1/11/17) at https://www.microsoft.com/en-us/download/details.aspx?id=48593 did the trick for me.
I had the same problem. TypeScript tools in VisualStudio 2015 and TypeScript packages attached to project had different versions that is why build failed with "The "VsTsc" task could not be initialized with its input parameters". I reinstalled TypeScript tools for VisualStudio 2015 (get older vertion) it solved my problem.
I had a similar problem.
For me the solution was:
Remove "Microsoft.TypeScript.Compiler" package
Remove "Microsoft.TypeScript.MSBuild" package
from installed packages.

Visual Studio 2010 and TFS 2008: Building unit test projects

We are currently taking VS2010 for a testdrive and so far we are a little stumped with how it just won't cooperate with our existing Team Foundation Server 2008.
We still have all our projects on .NET 3.5 and whenever we are now building a solution that contains a unit test project (which automatically builds in .NET 4.0) the TFS won't build it.
The .NET 4.0 framework is installed on the TFS 2008.
The error we're receiving is:
[Any CPU/Release] c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(0,0): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
As a temporary workaround we are now forced to remove all our test projects in order for our solutions to build.
You need to install VS2010 on your build machine.
I'v just been trying to build V4.0 solutions on TFS2008, and altered the C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\tfsbuildservice.exe.config file:
<add key="MSBuildPath" value="" />
to
<add key="MSBuildPath" value="c:\Windows\Microsoft.NET\Framework\v4.0.30319\" />
The build of v3.5 and v4.0 solutions did succeed. But the unittest of the v3.5 solutions did not work.
Read about installing VS2010 on the build server, but read somewhere else: ( http://www.richard-banks.org/2009/11/how-to-build-vs2010-solutions-using.html ) that it is possible without installing VS2010.
: Text from that website:
This worked for us allowing a TFS 2008 build agent compile VS 2010 solution/project files without installing VS 2010:
Install .NET Framework 4.0 and .NET Framework 3.51 SP1 (for some reason, SP1 wasn't included with 4.0?)
Install Windows SDK 7.0A. When I'm writing this the SDK is still not released so we had to:
From a computer with VS 2010 installed, copy the SDK folder from %programfiles%\Microsoft SDKs\Windows\v7.0A and registry settings from HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\7.0A to the build machine.
Copy %programfiles%\MSBuild\Microsoft\VisualStudio\v10.0 to the build machine
Change ToolsVersion from 3.5 to 4.0 in your TFSbuild.proj file.
I think that was all. There was no need to change the build agent's configuration file.
Hopefully this will work.
Install "Agents for Visual Studio 2012"
http://www.microsoft.com/en-us/download/details.aspx?id=38186