I have a solution that contains multiple projects. They are a mix of c/c++, .NET framework, .NET Standard and .NET Core. Previously it was just c/c++ and .NET framework but we've now upgraded most of them.
I'm trying to modify an existing CI pipeline using VSTS that will build and publish the relevant projects now they've been converted to dotnet core/standard.
I can't use dotnet build
to build this solution due to the incompatible projects so I'm using the Visual Studio Build task instead. That works fine.
When it comes to testing, I can't use the visual studio test task as that fails. Instead, I use dotnet vstest
and target the already built unit test project dll. This isn't great but it works. I have to use the --no-build
switch to ensure it doesn't try and build the project as that will fail due to the incompatible projects.
For publishing the main application project, I need to use dotnet publish
. However, when I do this I get errors like
error MSB3030: Could not copy the file "xx\bin\release\netstandard2.0\xx.dll" because it was not found. [xx.csproj]
This is because it's looking in the wrong place. The files are actually in xx\bin\x64\release\netstandard2.0. I can specify the release/debug configuration using dotnet publish -c <release|debug>
but it seems I cannot specify the platform part of the path.
To resolve this, I changed the configuration to build to xx\bin\release\netstandard2.0\ instead. However, it still failed with a similar error relating to the xx\obj\ path.
I've tried using the -r switch in conjunction with RuntimeIdentifiers in the project file but that does not seem related to this issue.
I've also tried running these commands locally for faster turn around and playing with the settings but no luck there either. I'm out of ideas.
Edit:
I have a (rather unsatisfactory) solution. If I edit all the project files to include the text below then the files are output to the expected locations and publish will work:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutputPath>bin\Release</OutputPath>
<IntermediateOutputPath>obj\Release</IntermediateOutputPath>
</PropertyGroup>
I can't believe I need to do this though. Is this really the only answer? Can I not pass something to dotnet publish
to get it to look in the right place?