I need to create a Nuget of project A which is dependent on project B (not a nuget project, local one).
I have added Project B as project dependency to project A and enabled property to generate package on build. It is creating nuget package file but not including all the files from project A.
I tried few things and google also but not finding much help.
I found one similar question Build NuGet Package automatically including referenced dependencies
but not working. I am able to create pkg but with few files copied over. while I can see all the files in debug folder. No idea on what basis Nuget is picking few files from project A.
Can anyone tell me what's wrong here.
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>1.0.0.0-alpha</PackageVersion>
<Platforms>x64</Platforms>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PlatformTarget>x64</PlatformTarget>
<NoWarn></NoWarn>
<WarningsAsErrors />
<OutputPath>bin\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<NoWarn></NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<OutputPath>bin\Release</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="someProject.csproj">
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<IncludeAssets>all</IncludeAssets>
</ProjectReference>
</ItemGroup>
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="#(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/>
</ItemGroup>
</Target>
</Project>
Related
While building the C# project locally/CI server, I wanted to control the NuGet package reference in the .csproj file. If the developer is building a C# project on github master branch (locally/CI server) I would like to add RC build NuGet package reference otherwise PRE releases NuGet package reference. How to do this? Can someone please assist me?
Some thoughts like -
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<GitBranch>$(GitBranch.Trim())</GitBranch>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitInfo" Version="2.2.0" />
</ItemGroup>
<Choose>
<When Condition="$(GitBranch) == 'master'">
<ItemGroup>
<PackageReference Include="Data.Account.Domain.Messaging" Version="1.0.0-rc*" IncludePrerelease="true" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="Data.Account.Domain.Messaging" Version="1.0.0-pre*" IncludePrerelease="true" />
</ItemGroup>
</Otherwise>
</Choose>
</Project>
You could read the git branch from the .git/HEAD file. Naive implementation like
<PropertyGroup>
<GitBranch>$([System.IO.File]::ReadAlltext('$(MsBuildThisFileDirectory)\.git\HEAD').Replace('ref: refs/heads/', '').Trim())</GitBranch>
</PropertyGroup>
You might want to adjust how you get the path to that file, and perhaps use something more robust (e.g. if you just checkout a random commit in git, the file won't contain a branch name but a commit SHA)
You could also use variable $(GitRoot) from GitInfo itself to build the path, just a small adaption to the existing code but helped for my case where I had to deal with nested folders.
<PropertyGroup>
<GitBranch>$([System.IO.File]::ReadAlltext('$(GitRoot)\.git\HEAD').Replace('ref: refs/heads/', '').Trim())</GitBranch>
</PropertyGroup>
At the moment I'm trying to setup a solution with a implementations class library and an abstractions project. I want to have both packages on nuget.org.
Normally when you're just using ProjectReferences, you'd only have to point to the csproj:
Random.Abstractions:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Abstractions for the Randomizer</Description>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Company>MyCompany</Company>
<Authors>Pieterjan De Clippel</Authors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
</ItemGroup>
</Project>
Random
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Random.Abstractions\Random.Abstractions.csproj" />
</ItemGroup>
</Project>
But off course when you build a nuget package, you don't want the Random.Abstractions.dll to be inside the Random nuget package, but the Random package to depend on the Random.Abstractions package. But since this package doesn't exist yet, you can't build it yet.
Microsoft is able to solve this problem like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
</PropertyGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
...
<Reference Include="Microsoft.AspNetCore.DataProtection.Abstractions" />
</ItemGroup>
</Project>
So this is neither a ProjectReference nor a PackageReference, which is why they are able to:
build and test the solution locally (so there they'd be acting as ProjectReferences)
push the code to GitHub and let the GitHub Actions create and publish the new version of the packages, while they depend on each other (so there they'd be acting as PackageReferences)
I've tried doing the same in my solution, but the project containing the concrete implementations is unable to find the abstractions project:
MyCompany.Random.Abstractions.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Abstractions for the Randomizer</Description>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Company>MyCompany</Company>
<Authors>John Wick</Authors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
</ItemGroup>
</Project>
MyCompany.Random.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="MyCompany.Random.Abstractions" />
</ItemGroup>
</Project>
So no ProjectReference (we don't want the dll to be in this nuget package), no PackageReference (the package is not yet published), but just Reference.
But somehow I'm still getting an error that the Abstractions assembly cannot be found:
I've checked the NuGet.config but there's nothing really special in there.
How can I use the Reference tag in a dotnet-based project, in order to reference to code while building/testing locally and reference the new package while building/pushing in a CI pipeline?
Reference to Microsoft.NET.Sdk documentation
Update:
#pinkfloydx33, you're right. I can see only one assembly/dll inside the nupkg:
Update 2:
I added the Microsoft.SourceLink.GitHub package to my project, and after downloading/unzipping the new version of my package I can see the following nuspec:
Where 77b181a24a83e46b4c80376f65bb305bedba1a64 is the commit ID.
Thanks for the tip.
I'm trying to build a single NuGet package that can be installed in Xamarin.Android, Xamarin.iOS, Xamarin.UWP and Xamarin.Forms (.NET Standard) projects. I can't use .NET Standard since I need to have a custom Activity for my Android project, custom AppDelegate for my iOS project, and a custom MainPage for my UWP project. In the initiators I want to use the ServiceCollection as DI provider.
In the docs they still mention the Portable Class Library (explicitly mentioned legacy, doesn't exist anymore in VS), or Manually Creating Packages (can't figure out what to do here), and then you also have websites mentioning the Xamarin.Forms Plugin, which also doesn't exist anymore.
I already made a solution with all 4 projects, but I can't figure out how I can create a single NuGet package for all 4 projects (all 3 target platforms).
Does anyone have an idea how we can build a multi-target NuGet package containing code for Android, iOS, and UWP, just like the Xamarin.Forms NuGet package?
I've also seen discussions like this: How does one create a project to create a Nuget package for Xamarin Forms supporting iOS, Android, and UWP?, but I'm not sure if this is still relevant, since the build.props and build.targets no longer exist in the MvvmCross repo.
On starting point is https://github.com/onovotny/MSBuildSdkExtras
A year ago, I made a sample (and collected some documentation and references), which might be inspiring for this subject: https://github.com/ZeProgFactory/MSBuildSdkExtrasTest
and https://github.com/ZeProgFactory/MediaPlayer is using it
And definitively, you should look at the repositories of James Montemagno's components at https://github.com/jamesmontemagno
With these references you should be able to start. But all of these had a mayor difference with your approach:
they are using one project (via MSBuildSdkExtras),
which is builded for all the platforms
and, finally, the binaries are assembled in one NuGet.
Perhaps you may take only this last step. Anyway, this approach is at least an option.
Hope this helps …
I've pushed a working version to https://github.com/MintPlayer/MintPlayer.MVVM
csproj-file
<Project Sdk="MSBuild.Sdk.Extras/2.0.41">
<!-- You must have the Android 8.0 SDK installed through the Android SDK manager -->
<PropertyGroup>
<AssemblyName>MintPlayer.MVVM</AssemblyName>
<RootNamespace>MintPlayer.MVVM</RootNamespace>
<TargetFrameworks>netstandard2.0;Xamarin.iOS10;MonoAndroid80;uap10.0.16299</TargetFrameworks>
<_WriteTelemetryProperties>false</_WriteTelemetryProperties>
<Authors>Pieterjan De Clippel</Authors>
<Company>MintPlayer</Company>
<Product>MintPlayer.MVVM</Product>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Description>This package allows you to implement ViewModel Navigation and Dependency Injection in a Xamarin.Forms project</Description>
<Version>1.0.0</Version>
<Copyright />
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/MintPlayer/MintPlayer.MVVM</PackageProjectUrl>
<RepositoryUrl>https://github.com/MintPlayer/MintPlayer.MVVM</RepositoryUrl>
<PackageTags>Xamarin.Forms, Viewmodel navigation, Dependency Injection</PackageTags>
<PackageReleaseNotes>This package is still under construction</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Platforms\**\*.cs" />
<None Include="Platforms\**\*.cs" />
<None Include="Resources\*.cs" />
<Compile Remove="Resources\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('uap')) ">
<Compile Include="Platforms\UAP\**\*.cs" />
<Compile Include="Platforms\Common\**\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) ">
<Compile Include="Platforms\Common\**\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) ">
<Compile Include="Platforms\iOS\**\*.cs" />
<Compile Include="Platforms\Common\**\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<Compile Include="Platforms\Android\**\*.cs" />
<Compile Include="Platforms\Common\**\*.cs" />
<AndroidResource Include="Resources\**\*.xml" SubType="Designer" Generator="MSBuild:UpdateAndroidResources" />
<AndroidResource Include="Resources\**\*.axml" SubType="Designer" Generator="MSBuild:UpdateAndroidResources" />
</ItemGroup>
<ItemGroup>
<None Remove="Platforms\Common\MintPlayerMvvmExtensions.cs" />
<None Remove="Platforms\Common\NavigationService.cs" />
<None Remove="Platforms\Common\Platform.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.6" />
<!--<PackageReference Include="Xamarin.Forms" Version="4.5.0.495" />-->
<PackageReference Include="Xamarin.Forms" Version="3.1.0.697729" />
</ItemGroup>
</Project>
Directory.build.props
<Project>
<PropertyGroup>
<Company>MintPlayer</Company>
<Copyright>Copyright © MintPlayer</Copyright>
<RepositoryUrl>https://github.com/MintPlayer/MintPlayer.MVVM</RepositoryUrl>
<Authors>Pieterjan De Clippel</Authors>
<Owners>MintPlayer</Owners>
<PackageReleaseNotes />
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<NeutralLanguage>en</NeutralLanguage>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);1591;1701;1702;1705;VSX1000;NU1603</NoWarn>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' and '$(IsTestProject)' != 'true'">true</GeneratePackageOnBuild>
<Platform>AnyCPU</Platform>
<DebugType>portable</DebugType>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IsTestProject>$(MSBuildProjectName.Contains('UnitTests'))</IsTestProject>
</PropertyGroup>
</Project>
Directory.build.targets
<Project>
<PropertyGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
<DefineConstants>$(DefineConstants);NETSTANDARD;PORTABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA;IOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('MonoAndroid'))">
<DefineConstants>$(DefineConstants);MONO;ANDROID</DefineConstants>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
</PropertyGroup>
</Project>
You must add the following to your .sln file
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7004E39A-BAF2-4F2F-B505-CC3DEC393CB6}"
ProjectSection(SolutionItems) = preProject
Directory.build.props = Directory.build.props
Directory.build.targets = Directory.build.targets
EndProjectSection
EndProject
I have the following folder structure (following the feature-oriented organization):
Solution
bin
obj
src
Module1
Shared.cs
Module2
Shared.cs
Module3
Shared.cs
Server
Program.cs
Startup.cs
Database
Program.cs
Solution.sln
Server.csproj
Database.csproj
For the Server project I am using Microsoft.NET.Sdk and Microsoft.NET.Sdk.Web for the Database.
Here is the actual Server.csproj:
<Project>
<PropertyGroup>
<TargetFramework>NetCoreApp3.1</TargetFramework>
<Configuration Condition=" '$(Configuration)' == '' ">Development</Configuration>
<EnvironmentName>$(Configuration)</EnvironmentName>
<BaseOutputPath>bin/$(MSBuildProjectName)</BaseOutputPath>
<OutputPath>$(BaseOutputPath)/$(Configuration)</OutputPath>
<BaseIntermediateOutputPath>obj/$(MSBuildProjectName)</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
<AppendTargetFrameworkToOutputPath>False</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>False</AppendRuntimeIdentifierToOutputPath>
<EnableDefaultContentItems>False</EnableDefaultContentItems>
<Nullable>Enable</Nullable>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<RootNamespace>OeMis.Server</RootNamespace>
<StartupObject>OeMis.Server.ServerEntry</StartupObject>
</PropertyGroup>
<ItemGroup>
<Content Include="Configuration.$(Configuration).json" ExcludeFromSingleFile="True" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest"/>
<PackageReference Include="Dapper" Version="2.0.30"/>
<PackageReference Include="HotChocolate" Version="11.0.0-preview.95"/>
<PackageReference Include="HotChocolate.AspNetCore" Version="11.0.0-preview.95"/>
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="11.0.0-preview.95"/>
<PackageReference Include="HotChocolate.AspNetCore.Playground" Version="11.0.0-preview.95"/>
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.0-preview1.20021.1"/>
</ItemGroup>
<Import Sdk="Microsoft.NET.Sdk.Web" Project="Sdk.props"/>
<Import Sdk="Microsoft.NET.Sdk.Web" Project="Sdk.targets"/>
</Project>
And here is the Database.csproj:
<Project>
<PropertyGroup>
<TargetFramework>NetCoreApp3.1</TargetFramework>
<Configuration Condition=" '$(Configuration)' == '' ">Development</Configuration>
<EnvironmentName>$(Configuration)</EnvironmentName>
<OutputType>Exe</OutputType>
<BaseOutputPath>bin/$(MSBuildProjectName)</BaseOutputPath>
<OutputPath>$(BaseOutputPath)/$(Configuration)</OutputPath>
<BaseIntermediateOutputPath>obj/$(MSBuildProjectName)</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
<AppendTargetFrameworkToOutputPath>False</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>False</AppendRuntimeIdentifierToOutputPath>
<EnableDefaultContentItems>False</EnableDefaultContentItems>
<Nullable>Enable</Nullable>
<RootNamespace>OeMis.Database</RootNamespace>
<StartupObject>OeMis.Database.DatabaseEntry</StartupObject>
</PropertyGroup>
<ItemGroup>
<Content Include="Configuration.$(Configuration).json" ExcludeFromSingleFile="True" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest"/>
<PackageReference Include="Dapper" Version="2.0.30"/>
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.0-preview1.20021.1"/>
<PackageReference Include="Bogus" Version="29.0.1"/>
</ItemGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props"/>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets"/>
</Project>
I always get errors in src/Server/Program.cs as if Database.csproj is trying to handle it. The errors have to do with missing references classes in Microsoft.NET.Sdk.Web.
The full project can be found on GitHub
This actually makes sense. You are trying to build the same source files with different dependencies.
My advise is to extract the common/shared items from both and add the to a new project called shared (preferable in .Net standard) and reference the libraries in both your projects.
Creating a class library for .net core guide here
TL;DL;
Create a Solution and Client App.
Create a Class Library Project.
Add Class Library Functionality.
Settings.
Build.
Add Class Library Reference.
Import Namespace.
Call Functions.
I have a project set up like this:
MainProject.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeIdentifiers>win10-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Project1\Project1.csproj" />
<ProjectReference Include="..\Project2\Project2.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="mark.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Project1.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<OutputTypeEx>library</OutputTypeEx>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.0.16</Version>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DebugType>full</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard1.6|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard1.6|x64'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.1" />
</ItemGroup>
</Project>
Project2.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Project1\Project1.csproj" />
</ItemGroup>
</Project>
I have configured publishing the project using Right click -> Publish like this:
Profile Name: FolderProfile
Configuration: Release
Target Framework: netcoreapp1.1
Target Runtime: win10-x64
Target Location: bin\Release\PublishOutput\Win10
Whenever I try to publish the project (in release mode), Visual Studio decides to use old Debug-builds of Project1 and Project2 instead of the new Release builds. I have traced the issue to the Roslyn csc command that Visual Studio is executing. In the output console I see this:
[ Build output of all Release builds ]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705,2008 /nostdlib+ /platform:x64 /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETCOREAPP1_1 /errorendlocation /preferreduilang:en-US [...] /reference:D:\Workspace\MySolution\Project1\bin\Debug\netstandard1.6\Project1.dll /reference:D:\Workspace\MySolution\Project2\bin\Debug\netstandard1.6\Project2.dll [...]
Note how it's actually using the bin\Debug files instead of the bin\Release files.
How do I force Visual Studio to use the Release builds instead of the outdated Debug builds when publishing?