An assembly specified in the application dependencies manifest (...) was not found - asp.net-core

I upgraded Microsoft.AspNetCore from 2.0.3 to 2.0.5 and my WebAPI project, although running successfully locally, fails to start in production (IIS). Everything was fine in production until this upgrade. The error message produced in the log directory is as follows:
Error:
An assembly specified in the application dependencies manifest (MyProject.WebAPI.deps.json) was not found:
package: 'Microsoft.AspNetCore.Mvc.Abstractions', version: '2.0.2'
path: 'lib/netstandard2.0/Microsoft.AspNetCore.Mvc.Abstractions.dll'
This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
aspnetcore-store-2.0.5.xml
Could someone explain to me the details of exactly what this means? I assume it's a version mismatch of sorts, but why is this occurring? I thought the latest stable releases of NuGet packages weren't supposed to have such issues.
I was able to resolve the issue by downgrading Microsoft.AspNetCore.All from 2.0.5 to 2.0.3, but would like to find a better solution to the issue so I can use the most up-to-date version of this package.

Development machines usually have the SDK installed but on production the runtime only.
Add the following to your .csproj file and publish again.
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

Sometimes this is related to the Startup Project, For example if the migration is a class library in Azure Functions project. You have to make sure when you run Add-Migration while the EF Library project is selected as Startup Project.

For me, the marked answer didn't solve the issue. My issue was when trying to Add-Migration
Add-Migration -Name initial-migration -Context Mysln.Data.MyDbContext -StartupProject Mysln -Project Mysln.Core
And the error was like this:
I solved it by downgrading all my Entityframework packages to 2.0.0 instead of the latest 2.2.0-preview one.

If you have more than one project in your solution like me:
and if you want to scaffold dbcontext in your "non startup" project (InstantOrder.Functions.Data in my case)
then you should add the -StartupProject parameter of the Scaffold-DbContext command like this -
Scaffold-DbContext "Server=..." -Project InstantOrder.Functions.Data -StartupProject InstantOrder.Functions.Data

I know this may be old, but just in case it can help some one else, this one worked for me:
Adding:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
To the PropertyGroup in the .csproj file.

To solve the first half of the error message, An assembly specified in the application dependencies manifest (…) was not found be sure to always use the publish output when deploying to a target sever.
For a self-contained application it can be found in
bin\Release\netcoreapp2.0\win81-x64\publish
or for framework-dependent deployments in
bin\Release\netcoreapp2.0\publish
The output in the directories above are meant to be used in development only, since they are specific to machine and user configuration built with.
Taken from a related answer.

2 cents: If you just take from the build folder, the dlls for the dependency aren't provided. If you publish the folder, they are. This was the fix for me.

I had this error however my solution was somewhat different from what was posted above. My problem was that I was deploying via a zip file and while building the zip file I wasn't including sub directories therefore required files were not being included.
So if you are publishing via a zip file make sure to include all sub folders while building the zip.

I got this error while running Scaffold-DbContext command on the Library project.
Solution:
Remove the Azure Function project from the solution, and then run this command.
After that, use add an existing project feature to add the Azure Function project again in the solution.

The correct .NET Core runtime was not installed on my PC. I had NETCore.App 2.1 and 2.2, but the project was targeted to 2.0.
dotnet --list-runtimes
I installed the correct runtime from the dot.net site and it resolved the issue.

In most case you get that error because there's misalignment of versions.
I changed the Microsoft.VisualStudio.Web.CodeGeneration.Design version, an it worked.
Before
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
After
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.4" />

This happened to me when I published my Lambda to AWS after renaming the project. I deleted both the obj and bin folders, rebuilt, republished and that fixed it.

I changed filters in Yaml.
Had projects called TestHelper etc...
Testrunner tried to run projects without tests, and the build was flagged as failed.
Added:
!**\*Helper*.*
To:
- task: DotNetCoreCLI#2
inputs:
command: 'test'
projects: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
!**\*TestPlatform*.dll
!**\*Testing*.*
!**\*TestHost*.*
!**\*Helper*.*

Related

Getting help on dotnet-aspnet-codegenerator debug output

I am scaffolding a local login identity page in into a asp.net core solution that already has default identity. I am doing this in order to customize my login page.
I have successfully done this using two test apps which use the same base code with progressively more packages installed) before attempting this on my final.
For my app, when I issue the following command, I'm getting this error:
PM> dotnet-aspnet-codegenerator identity --dbContext ApplicationDbContext
Failed to get Project Context for C:\Users\...\rollbase.csproj.
To see more information, enable tracing by setting environment variable 'codegen_trace' = 1
There is no information about 'codegen_trace' in docs.
I have searched and found a lot of references to this error. But can't find anything for:
What is the 'Project Context'
How do I use a 'codegen_trace'
The solution builds successfully.
I have been very careful keeping track of the packages involved
Microsoft.VisualStudio.Web.CodeGeneration.Design
Microsoft.AspNetCore.Identity.EntityFrameworkCore
Microsoft.AspNetCore.Identity.UI
Azure.Identity
Using
<TargetFramework>net5.0</TargetFramework>
dotnet-aspnet-codegenerator' (version '5.0.0')
dotnet sdk 5.0.403
Microsoft.NETCore.App 5.0.12
Most posts talk of rolling back the tool version/packages etc. I was wanting to know if anyone out there can actually point to a solid debug strategy.
I am adding info to this question below
Using help provided - output from codegen_trace
Microsoft.Extensions.ProjectModel.MsBuildProjectContextBuilder.Build()
/_/src/Ext.ProjectModel.MsBuild.Sources/MsBuildProjectContextBuilder.cs:line 56
At Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program
.GetProjectInformation(String projectPath, String configuration) in
/_/src/dotnet-aspnet-codegenerator/Program.cs:line 290
At Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program
.BuildAndDispatchDependencyCommand(String[] args,
String projectPath, String buildBasePath, String configuration, Boolean noBuild, ILogger logger)
in /_/src/dotnet-aspnet-codegenerator/Program.cs:line 173
Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program
.<>c__DisplayClass19_0.<Execute>b__0() in
/_/src/dotnet-aspnet-codegenerator/Program.cs:line 129
From this output it looks like a problem in the installed package Microsoft.VisualStudio.Web.CodeGeneration.Tools 5.0.2
I have tried to update the package to 6.0,0 in Visual Studio 2019 (latest) but get the following:
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Design 6.0.0 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package Microsoft.VisualStudio.Web.CodeGeneration.Design 6.0.0 supports: net6.0 (.NETCoreApp,Version=v6.0)
I looked at the github repo for this project but could not find any documentation regarding compatibility with .NETCoreApp,Version=v5.0
With reference to the original error message:
PM> dotnet-aspnet-codegenerator identity --dbContext ApplicationDbContext
Failed to get Project Context for C:\Users\...\rollbase.csproj
I have compared the .csproj files for the project where codegenerator works against the one where codegenerator fails to get Project Context.
The main difference is in the Property Group.
The codegnerator works:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>aspnet-testbase1-57C4221E-46E9-4653-A734-4C412F7C523D</UserSecretsId>
</PropertyGroup>
Where Project Context not found:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>aspnet-rollbase-6D7D2449-EB25-45CE-A8D3-EDAB69CDCAB3</UserSecretsId>
<RootNamespace></RootNamespace>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<AssemblyName />
<PackageId />
<EnableNETAnalyzers>false</EnableNETAnalyzers>
</PropertyGroup>
The best way to understanding the codegen_trace environment variable and it's output is reading the source code.
To enable the Trace logs, set the codegen_trace environment variable before you run dotnet-aspnet-codegenerator:
Command Prompt
SET codegen_trace=1
PowerShell
$env:codegen_trace=1
Bash/Zsh/Fish
export codegen_trace=1
The Project Context means the context of the project information. Most of the project information included in *.csproj file. Your problem is very possible that your project can't build successfully. You have to make sure your project is buildable.
For your dotnet-aspnet-codegenerator identity --dbContext ApplicationDbContext command, you at least need to install the following packages to get things right.
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.AspNetCore.Identity.UI
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
Please check the version of your code generator CLI tool version is the same as with your.NET version. You need to set the codegen_trace as an Environmental variable like this if you're in Linux or mac
codegen_trace=1
If you're using Powershell you can set it like this.
$env:codegen_trace=1
There is a GitHub open issue related to this. Please check the solutions on that as well. - https://github.com/dotnet/Scaffolding/issues/1388
I edited the project file PropertyGroup section. From what it was (see additional info in question above) to:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>aspnet-rollbase-6D7D2449-EB25-45CE-A8D3-EDAB69CDCAB3</UserSecretsId>
</PropertyGroup>
Identity files were scaffolded using:
dotnet-aspnet-codegenerator identity --dbContext ApplicationDbContext
[Trace]: Command Line: identity --dbContext ApplicationDbContext
Building project ...
[Trace]: Command Line: --no-dispatch --port-number 52819 identity --dbContext ApplicationDbContext --dispatcher-version 5.0.0+a93dad81ee7f820d8e33d3f91e066ef68053d004
Finding the generator 'identity'...
Running the generator 'identity'...
...etc...

How to kill VBCSCompiler.exe on Ubuntu agent?

I created an Azure Devops Build pipeline and i am trying to build my ASP.NET MVC and Angular hybrid site project on bitbucket (git).
The project first gets checked out, and nuget restores the necessary packages, and then the .NET builds. I used windows 2019 as azure pipeline agent for the build to succeed. however, Its taking about 7 minutes to complete, whilst running the tasks (besides .Net) on a ubuntu agent is much faster! takes around 2 mins instead!
Therefore, I'd like to use ubuntu, but im running into an issue with the MSBuild task...
"/home/vsts/work/1/s/Bobby.ProjectA/Bobby.ProjectA.csproj" (default target) (1) ->
(KillVBCSCompilerAndRetryCopy target) ->
/home/vsts/work/1/s/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8/build/net45/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(23,5):
error MSB4044: The "KillProcess" task was not given a value for the required parameter "ImagePath". [/home/vsts/work/1/s/Bobby.ProjectA/Bobby.ProjectA.csproj]
According to this post, VBCSCompiler.exe continues running from the Compiler Nuget package (nuget restore task?) so it locks the src folders and prevented future builds from running, e.g. causing error like this:
/home/vsts/work/1/s/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8/build/net45/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(17,5):
warning MSB3021: Unable to copy file "/home/vsts/work/1/s/packages/Microsoft.Net.Compilers.2.4.0/build/../tools/csc.exe" to "/bin/roslyn/csc.exe". Access to the path '/bin/roslyn' is denied. [/home/vsts/work/1/s/Bobby.ProjectA/Bobby.ProjectA.csproj]
So the solution would be to kill the VBCSCompiler.exe but since i cant actually access the hosted machine during the build, im not sure how to do that.
screenshot of my pipeline so far:
Am i facing a dead-end path here with this approach? The build runs fine on windows 2019 but it just takes too long, so thats why if i can make it run on ubuntu successfully that would be great!
You can have a try with below workarounds:
1,Set MSBUILD arguements /p:UseSharedCompilation=false.
You can add above arguement to the msbuild arguements field of the msbuild task. See here.
2,Upgrade Microsoft.CodeDom.Providers.DotNetCompilerPlatform nupkg to the latest and remove Microsoft.Net.Compilers nupkg from your project. See here for more information.
3, Try Specifing the TTL of Roslyn compiler server.
You can define a pipeline variable VBCSCOMPILER_TTL on the Variable tab to specify a shorter idle time for VBCSCompiler.exe
Or you can add <providerOption name="CompilerServerTimeToLive" value="[num of seconds]" /> under system.codedom/compilers/compiler in the config file. See here for more information.
4, Use CheckIfShouldKillVBCSCompiler target:
You can try add below to your csproj file:
<Target Name="CheckIfShouldKillVBCSCompiler">
<PropertyGroup>
<ShouldKillVBCSCompiler>true</ShouldKillVBCSCompiler>
</PropertyGroup>
</Target>
See here.
The build on Ubuntu 20 finally worked! I don't know why removing these lines resolved the VBCSCompiler issue, but by doing so, the msbuild completed successfully on Ubunutu 20 agent!!
Remove the following lines from the .csproj file:
<Import Project="..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" />
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
To give some context to the answer, this post here indicated that converting from MSBuild-Integrated Package Restore to Automatic Package Restore (nuget restore task) implied that the Microsoft.Net.Compilers <Import> and <Error Condition> snippets are no longer relevant/needed in the .csproj file.

Code builds fine in VS (2017) but not msbuild or TFS "assemblies manifest does not match the assembly reference

OK - here we go again. I posted an almost identical question here, but this one is a little different. I just generated a new version of a NuGet package and updated all of our csproj and config files to point to it and it builds locally fine, but when I kick off a TFS build it fails with the message:
##[error]ASPNETCOMPILER(0,0): Error ASPCONFIG: Could not load file or assembly 'PacsgearLib, Version=2.5.4.0, Culture=neutral,
PublicKeyToken=05b30ac9ab9dbb8e' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
Pacsgearlib 2.5.4 is the NuGet package I just generated, but all of our other projects build fine (and they share a lot of the same code). The main difference is that this project has a website in it. MSBuild is version 15.5.180.51428.
Here's a picture of the actual error:
Any ideas here? I've tried NuGet package manager to uninstall the package and reinstall it for the website and that hasn't helped.
I've been at this for a few hours so I thought maybe someone else (or a second set of eyes) might help.
I also just saw this and will check it out first thing Monday morning.
I finally got this to work by taking out the assemblybinding section of the web.config (someone else suggested that in another related post) and I also found a few .csproj files that had not been properly updated and were still pointing at 2.5.3.
If the local builds fine, and the error exist with TFS build. Besides, all of our other projects build fine (and they share a lot of the same code).
Combine with both, the issue may related to the specific package PacsgearLib, Version=2.5.4.0 on build agent. You could try to delete the packages and clean build agent, then try again.
Another way is update your package version number(do not update the package content), use TFS trigger the build again. Check if TFS build server will pick up the latest version of package.
Also set system.debug=true to Enable Verbose Debug Mode with more detail log info for troubleshooting

TeamCity - Microsoft.Bcl.Build Dependency

I've just committed some code changes to my repository and all of a sudden (after weeks of being fine). The TC build starts failing as it fails to download the NuGet package for Microsoft.Bcl.Build.1.0.6.
I ended up having to manually copy the contents of the packages directory to the TC build location which utterly defeats the point of NuGet.
What can I check to get to the root cause of this?
Everything about NuGet is enabled in the solution for getting packages.
I've blogged about this issue at http://sedodream.com/2012/12/24/SlowCheetahBuildServerSupportUpdated.aspx. To summarize NuGet package restore (prior to 2.7) is implemented as a part of the MSBuild build process. When MSBuild starts a build it will evaluate the project file and any Import declarations importing other files. This happens before any target gets executed.
Since NuGet pkg restore is a part of the build process the .targets files get restored at a point in time that it is too late for the Import statement to have any impact.
You can work around this by either checking in the .targets file as you stated, or by invoking pkg restore before the build process. I've created a NuGet package, PackageRestore, which can help with the latter approach.
To use PackageRestore just add the NuGet package to your project which will automatically create a file named packageRestore.proj in your projects directory. When configuring your build, you will need to build that item before your .sln/.csproj file.
OK This is a bit of a nasty issue.
If you are having this problem you need to do something rather ugly to your repository.
Make sure you are checking in the packages\repositories.config file.
Then if your build is failing with unresolved references to Microsoft.Bcl.Build you will need to also checkin the .targets file for this package. eg:
package\Microsoft.Bcl.Build.x.x.x\tools\Microsoft.Bcl.Build.targets
Hideous ...
This blog post is the most thorough one I've seen for explaining the workaround options:
http://blogs.msdn.com/b/dotnet/archive/2013/06/12/nuget-package-restore-issues.aspx
None are great IMO - this problem still needs a better solution.
But for the time being, the best recommended option is to check the Bcl.Build .targets file into source control - which means when the version of Bcl.Build is updated, you'll need to add the new .targets file, and remove the old one.
I think (but am not sure, so I created this SO question: What does the Microsoft.Bcl.Build NuGet package do?) that Microsoft.Bcl.Build is only needed for development, and is not needed on a build server. So, I have a Builder.targets file that only exists in the build environment, that is indirectly <import> ed into all of our projects, which includes this bit of MSBuild xml:
<!-- Skip Microsoft.Bcl.Build functionality when building only from Source. Presumably Microsoft.BclBuild is only needed for development. -->
<PropertyGroup>
<BclBuildImported>Ignore</BclBuildImported>
</PropertyGroup>
Since the block of MSBuild logic inserted into your project by the Bcl.Build nuget package is dependent on the BclBuildImported property being empty, this effectively sidesteps the problem in my build environment - the Microsoft.Bcl.Build steps are skipped, and it no longer breaks my CI builds.
Note that since it appears that this package manages binding redirects in your app.config, and ensures that transitive dependencies are included in your projects, it's important to leave in for development. But I'm not currently aware of a need for it in a build server environment.

The OutputPath property is not set for project

Building my Jenkins/MSBuild solution gives me this error
c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9): error :
The OutputPath property is not set for project '<projectname>.csproj'. Please check to
make sure that you have specified a valid combination of Configuration and Platform
for this project. Configuration='Latest' Platform='AnyCPU'. You may be seeing this
message because you are trying to build a project without a solution file, and have
specified a non-default Configuration or Platform that doesn't exist for this project.
[C:\<path>\<projectname>.csproj]
Any ideas?
EDIT
I have this in my .csproj file
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Latest|AnyCPU'">
<OutputPath>bin\Latest\</OutputPath>
</PropertyGroup>
I have figured out how it works (without changing sln/csproj properties in VS2013/2015).
if you want to build .sln file:
/p:ConfigurationPlatforms=Release /p:Platform="Any CPU"
if you want to build .csproj file:
/p:Configuration=Release /p:Platform=AnyCPU
notice the "Any CPU" vs AnyCPU
check the code analysis, fxcop, test coverage(NCover) targets, as well as the MSBUILD should be located properly. In my case its:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
but it can be different as you can see microsoft has given 6 cmd options to build code base::AMD (with cross plt, x86 & x64 options) and Windows(cross, x86, x64) and that also when code development happened with default JIT (it can be PreJIT ngen.exe, econoJIT)
I think more than this troubleshooting can be handle using power shell + msbuild. May be helpful for someone ...
Open up your csproj in a text editor and see if you have a property group section, should look something like this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Latest|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Latest\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
Do you have a 'Latest' build configuration? If not add the above section to the csproj.
As mentioned by perlyking, rather than editing the csproj XML The following worked for me. Here are the steps I used.
Open the Project Properties.
Select the Build Tab.
Under the Output section, Check that an output path is set. (if not set one, save the project and it should work).
If it is set, click on the "Browse..." button of the output path.
When the folder selection dialog opens, Navigate up one level in the
file browser and then re-select the output folder and click
the "Select Folder" button.
Save the project properties and it should work.
To add to what #James said, I found that if I looked at the project Compile properties in VS2013, the Build Output Path was specified. But when I examined the .csproj file directly, the OutputPath element was missing for the relevant build configuration. So in VS I simply made and reversed a minor edit to the output path, saved it, and that kicked the value into the project file, and I was then able to build.
I was using MSBuild to build multiple .sln files, and had added a new step to build a .csproj file as well, when I encountered this error.
#Saurabh's answer highlighted the root of the problem. However, when fixing it, adding /p:Platform=AnyCPU to the MSBuild Arguments section didn't fix it. I actually needed to update the Platform value on the build step.
All other build steps were using the $(BuildPlatform) variable value (which happened to be "any cpu", with a space in it).
(Had I been building multiple .csproj files, I probably would have created a second variable for the AnyCPU platform.)
For me the answer was to fix all the projects in Build > Configuration Manager.
If you have some projects where the name or platform does not match the solution configuration, you should change it so they all match.
I was running into this issue while updating an older project with additional project configurations for per-environment config transforms.
It turns out that when the project configurations were added to the csproj file, they were inserted after an Import element which caused the issue.
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ProjectName.Dev|AnyCPU'">
...
Moving the Import element after all the PropertyGroup definitions fixed the problem for me.
Relevant similar case: https://stackoverflow.com/a/31072208/2452820
I got this error only when I was publishing my web project. I had mistakenly selected the wrong build configuration when setting up the publish profile.
I had same issue. I have updated my windows platform by using command line. Currently i got updated to windows#5.0.0 version. Then you need to search for file name "SQLite3.UWP.vcxproj". Try to change "v141" to "v140". Currently I am using Visual Studio 2015 professional. If it's Visual Studio 2017, then there is no need to change version in SQLite3.UWP.vcxproj file.
In my case this error happened because the output folder included a dot to make it relative to the current directory. The problem was solved by removing the dot.
The offending Build output path was:
.\bin\Output
The problem was solved by changing it to
bin\Output
The build output path can be found in the Build tab of the project properties, and there is a different path for each combination of Configuration and Platform.
Just had the issue for some service fabric stuff in MSBuild.
First step was right clicking each affected project and pulling up their Properties, selecting the Build tab, then setting the platform target to x64.
Second step was to go into the configuration manager and set each project to also use x64 for Debug and Release.
This was for a VS2017 project.
I had the same problem on a few projects. After adding a new configuration to the projects, the PropertyGroup was added at the very end of the Project file.
Moving the PropertyGroup to right after all the other configurations PropertyGroup fixed the issue.
I hope this helps.
I had this witha slightly unusual SLN/CSPROJ file arrangement:
I had project files:
A.csproj, with configurations "Dev" and "Production"
B.csproj, with configurations "Dev" and "Production"
C.csproj, a "common" library used by both A and B with configurations "Dev" and "Production"
And I had SLN files:
AC.sln, with configuration "Production" - this is used by jenkins to build project A and the common library
BC.sln, with configuration "Production" - this is used by jenkins to build project B and the common library
ABC.sln, with configuration "Dev" - this is used by developers in VS to write new code without having to keep opening different solutions (this answer is a simplified view of a 55-project solution)
I'd made an edit to the common library and introduced a dependency on project A. AC.sln would still build in jenkins but BC.sln gave an error saying:
The OutputPath property is not set for project 'A.csproj'. Please check to
make sure that you have specified a valid combination of Configuration and Platform
for this project. Configuration='Debug' Platform='AnyCPU'.
It was initially puzzling because we don't even have a Debug config anywhere in any project; find in files for Debug| turned up 0 hits
ABC.sln that the human developers use in VS would also build fine. Building BC.sln gave an error that A.dll wasn't found
When the circular irresolvable problem of C depending on A was removed, everything started working again
This error is misleading and can be caused by a different issue. Check the entire message:
The OutputPath property is not set for project 'myproject'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='myconfig' Platform='AnyCPU'. This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform.
My build configuration was missing this node in the csproj:
<PlatformTarget>AnyCPU</PlatformTarget>
Despite saying AnyCPU was the selected Platform in the dropdown, the actual xml was not there. Adding it fixed the mismatch between the project and the other project it was referencing.
The OutputPath property is not set for project error message will appear if a Platform environment variable exists (as seems to happen on HP laptops) and the target of MSBuild contains a reference to another Visual Studio project.
After renaming the Platform environment variable my build now works.
It seems the parameter /p:Platform="Any CPU" gets applied to the target solution but doesn't 'carryover' to referenced projects. In my instance, the error message indicated referenced projects were using the environment variable Platform=MCD.
I had two project configs, Debug and Release. When the Release build was used, it was throwing this error. The issue I found was that in the csproj file, the Debug config was near the top and the Release config was all the way at the bottom.
Manually moving the Release build just below the Debug build fixed it.
I'm assuming I did something incorrectly when setting up my build configurations because this doesn't feel like something I should have had to manually adjust.
Edit the properties of the project:
Make sure "Configuration Properties->General->Output Directory" is not blank. Note, it's not called OutputPath here. You can probably copy the value from Intermediate Directory.
I encountered the same problems when build TheXTech (https://github.com/Wohlstand/TheXTech/wiki/Building-on-Windows#building-in-visual-studio-201520172019-and-cmake) recently. And finally I found it is a cmake -A issue. The correct arch for 64 bit on windows is x64, not Win64.
For some more reference, see https://cmake.org/cmake/help/v3.16/generator/Visual%20Studio%2016%202019.html#platform-selection, https://cmake.org/pipermail/cmake/2019-April/069379.html.
Go to Solution properties and change the configuration to Any CPU or X64 or X86, and if build is checked uncheck that for what you are getting error for. By default, project build that for build configuration in solution and throw error as mentioned when building the project.