I would like to setup a CI/CD pipeline with build, test and deploy stages. I can build my project in build stage with
msbuild src\MyProject.csproj /t:Restore
msbuild src\MyProject.csproj /p:Configuration=Release /p:OutputPath=../BuildOutput
Next I will build and run tests against ..\BuildOutput\MyProject.dll that has already been built.
msbuild tests\MyProject.Tests.csproj /t:Restore
msbuild tests\MyProject.Tests.csproj /p:Configuration=Release /p:OutputPath=../BuildOutput /p:BuildProjectReferences=false
vstest.console BuildOutput\MyProject.Tests.dll
Up to this point it seems to work.
Now I would like to generate nuget package. I can call:
msbuild src\MyProject.csproj /t:Pack /p:Configuration=Release /p:OutputPath=../BuildOutput /p:VersionPrefix=1.2.3
And that would create MyProject.1.2.3.nupkg in BuildOutput folder.
However it re-builds that project.
I'm looking something similar to dotnet cli.
dotnet pack --no-build
But I cannot use dotnet because my project has a COM reference.
I also looked into Nuget.exe, but it seems to throw an error when I call nuget pack
Unable to cast object of type 'System.String' to type NuGet.Frameworks.NuGet.Frameworks1051960.NuGetFramework'.
Does msbuild have a property that can skip build?