I want to know whether the platform I'm building to is OSX. While I have gotten a working solution, it requires me to specify -r and -p:RuntimeIdentifier, and is also incredibly fragile. I know this isn't the right way to do it.
Right now I have something like
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<BuildingForOSX Condition="'$(RuntimeIdentifier.StartsWith(`osx`))' Or (('$(IsOSX)' == 'true') And ('$(RuntimeIdentifier)' == ''))">true</BuildingForOSX>
<BeautyEnable Condition="('$(BeautyEnable)' == '') And ('$(BuildingForOSX)' == 'true')">false</BeautyEnable>
<BeautyEnable Condition="'$(BeautyEnable)' == ''">true</BeautyEnable>
with
<PackageReference Condition="'$(BuildingForOSX)' == 'true'" Include="Dotnet.Bundle" Version="*" />
<PackageReference Condition="'$(BeautyEnable)' == 'true'" Include="nulastudio.NetBeauty" Version="2.0.0.0-beta.1" />
The goal is to:
Only download Bundle when the target platform is OSX
Only enable NetBeauty when the target platform is not OSX
What's the proper way to do this that makes both:
dotnet restore -r osx-arm64 work without -p:RuntimeIdentifier=osx-arm64, and
dotnet msbuild -p:RuntimeIdentifier=osx-arm64 -t:BundleApp work without applying NetBeauty?
Related
I have a VB.NET solution in Visual Studio 2013. I am using Nuget v2.12.0.817 (this is the lastest version available for Visual Studio 2013).
When I compile the solution I get an error that says:
Could not find a part of the path
I googled and it seems it is a problem with Nuget. I have done what was explained here as a workaround but without success. It consists on changing the space after $(SolutionDir) to a backslash in nuget.targets. My nuget.targets is as below:
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
Also, I have tried to change the 2 lines above to:
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT' and HasTrailingSlash('$(SolutionDir)')">"$(SolutionDir)\"</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT' and !HasTrailingSlash('$(SolutionDir)')">"$(SolutionDir)"</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
But Nuget continues adding a blank space at the end of the path and it does not work... Any ideas?
UPDATE 25/11/2019:
I updated VS 2013 to Update 5 some days ago and suddenly it started compiling correctly. Today I have compiled the solution again, and now again the error still continues appearing. I have installed Nuget 2.12.0.817 (the last available for VS2013). I do not understand anything...
I use Visual Studio 2017 and create a new ASP.NET Core project.
I add migration for Entity Framework Core as below
add-migration "Initial Create"
and get the following error:
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Add-Migration' for Entity Framework 6.
Build Failed.
Do you know how to resolve this error?
UPDATE 1 - March 14, 2017 - Result received after running command
PM> dotnet ef migrations add "Initial Create"
I see the following output with error message at the end.
Welcome to .NET Core!
---------------------
Learn more about .NET Core # https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The
data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry # https://aka.ms/dotnet-cli-telemetry.
Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up
to a minute to complete and will only happen once.
Decompressing 0%Decompressing 1%Decompressing 2%Decompressing 3%Decompressing 4%
Decompressing 5%Decompressing 6%Decompressing 7%Decompressing 8%Deco
mpressing 9%Decompressing 10%Decompressing 11%Decompressing 12%Decompressing 13
%Decompressing 14%Decompressing 15%Decompressing 16%Decompressing 17%
Decompressing 18%Decompressing 19%Decompressing 20%Decompressing 21%De
compressing 22%Decompressing 23%Decompressing 24%Decompressing 25%Decompressin
g 26%Decompressing 27%Decompressing 28%Decompressing 29%Decompressing 30%
Decompressing 31%Decompressing 32%Decompressing 33%Decompressing 34%
Decompressing 35%Decompressing 36%Decompressing 37%Decompressing 38%Decompre
ssing 39%Decompressing 40%Decompressing 41%Decompressing 42%Decompressing 43%
Decompressing 44%Decompressing 45%Decompressing 46%Decompressing 47%
Decompressing 48%Decompressing 49%Decompressing 50%Decompressing 51%Deco
mpressing 52%Decompressing 53%Decompressing 54%Decompressing 55%Decompressing
56%Decompressing 57%Decompressing 58%Decompressing 59%Decompressing 60%
Decompressing 61%Decompressing 62%Decompressing 63%Decompressing 64%
Decompressing 65%Decompressing 66%Decompressing 67%Decompressing 68%Decompress
ing 69%Decompressing 70%Decompressing 71%Decompressing 72%Decompressing 73%
Decompressing 74%Decompressing 75%Decompressing 76%Decompressing 77%
Decompressing 78%Decompressing 79%Decompressing 80%Decompressing 81%Decomp
ressing 82%Decompressing 83%Decompressing 84%Decompressing 85%Decompressing 86
%Decompressing 87%Decompressing 88%Decompressing 89%Decompressing 90%
Decompressing 91%Decompressing 92%Decompressing 93%Decompressing 94%De
compressing 95%Decompressing 96%Decompressing 97%Decompressing 98%Decompressin
g 99%Decompressing 100% 5083 ms
Expanding 0%Expanding 1%Expanding 2%Expanding 3%Expanding 4%Expanding 5%Ex
panding 6%Expanding 7%Expanding 8%Expanding 9%Expanding 10%Expanding 11%
Expanding 12%Expanding 13%Expanding 14%Expanding 15%Expanding 16%Expanding 17%
Expanding 18%Expanding 19%Expanding 20%Expanding 21%Expanding 22%Expand
ing 23%Expanding 24%Expanding 25%Expanding 26%Expanding 27%Expanding 28%
Expanding 29%Expanding 30%Expanding 31%Expanding 32%Expanding 33%Expanding 34
%Expanding 35%Expanding 36%Expanding 37%Expanding 38%Expanding 39%Ex
panding 40%Expanding 41%Expanding 42%Expanding 43%Expanding 44%Expanding 45%
Expanding 46%Expanding 47%Expanding 48%Expanding 49%Expanding 50%Expandin
g 51%Expanding 52%Expanding 53%Expanding 54%Expanding 55%Expanding 56%
Expanding 57%Expanding 58%Expanding 59%Expanding 60%Expanding 61%Expanding 62%
Expanding 63%Expanding 64%Expanding 65%Expanding 66%Expanding 67%Expa
nding 68%Expanding 69%Expanding 70%Expanding 71%Expanding 72%Expanding 73%
Expanding 74%Expanding 75%Expanding 76%Expanding 77%Expanding 78%Expanding
79%Expanding 80%Expanding 81%Expanding 82%Expanding 83%Expanding 84%
Expanding 85%Expanding 86%Expanding 87%Expanding 88%Expanding 89%Expanding 90%
Expanding 91%Expanding 92%Expanding 93%Expanding 94%Expanding 95%Expand
ing 96%Expanding 97%Expanding 98%Expanding 99%Expanding 100% 13884 ms
dotnet : No executable found matching command "dotnet-ef"
At line:1 char:1
+ dotnet ef migrations add "Initial Create"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (No executable f...and "dotnet-ef":String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
UPDATE 2 - March 14, 2017 - Startup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using OdeToFood.Services;
using OdeToFood.Entities;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
namespace OdeToFood
{
public class Startup
{
public IConfiguration Configuration { get; set; }
public Startup(IHostingEnvironment env)
{
// TN - Read setting files
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
}
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton(Configuration);
services.AddSingleton<IGreeter, Greeter>();
services.AddScoped<IRestaurantData, SqlRestaurantData>(); // TN - One instance of this service for each HTTP request.
services.AddDbContext<OdeToFoodDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<User, IdentityRole>()
.AddEntityFrameworkStores<OdeToFoodDbContext>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
//app.UseExceptionHandler("/error");
//app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandlingPath="/error" });
app.UseExceptionHandler(new ExceptionHandlerOptions
{
ExceptionHandler = context => context.Response.WriteAsync("Opps!")
});
}
//app.UseDefaultFiles();// TN - will pick index.html
//app.UseStaticFiles();
app.UseFileServer(); // TN - This will include UseDefaultFiles() and UseStaticFiles
/*
app.UseWelcomePage(new WelcomePageOptions
{
Path = "/welcome"
});
app.Run(async (context) =>
{
// TN - Read directly from configuration file
//var message = Configuration["Greeting"];
// TN - Dependency Injection - Read from configuration string via IOC
var message = greeter.GetGreeting();
await context.Response.WriteAsync(message);
});
*/
app.UseIdentity();
//app.UseMvcWithDefaultRoute();
app.UseMvc(ConfigureRoutes);
// TN - if no route matches
app.Run(ctx => ctx.Response.WriteAsync("Not found."));
}
private void ConfigureRoutes(IRouteBuilder routeBuilder)
{
//Home/Index
routeBuilder.MapRoute("Default",
"{controller=Home}/{action=Index}/{id?}");
}
}
}
Update 3 - March 14, 2017 - Added csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<!--<Content Include="wwwroot\index.html" />-->
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
<Folder Include="Data\" />
<Folder Include="Views\Home\" />
<Folder Include="wwwroot\images\" />
</ItemGroup>
</Project>
How I resolve this in VS 2017|2019
Remove EntityFramework (not EntityFrameworkCore) references from all projects in the solution
Open the solution folder in Explorer (Windows Explorer)
Close VS
delete folder
Open the solution again
Run update-database and the alert is gone
You cannot see '.vs' folder?
For those using the new port of Entity Framework 6.3 and later to .Net Core, there is a good chance that a solution will include both EfCore and Ef6 artifacts.
e.g. I had migrated an older EF6 repository from .Net Framework to Core, but wanted to make use of the out-of-the-box AspNet Identity Core subsystem, which uses EfCore.
Invariably, during migrations, I would aribtrarily receive errors like:
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework6\Update-Database' for Entity Framework 6.
or
Both Entity Framework 6 and Entity Framework Core are installed. The Entity Framework 6 tools are running. Use 'EntityFrameworkCore\Add-Migration' for Entity Framework Core
The solution is simple - when running migration commands, as per the warning, always qualify the commands with the fully qualified:
EntityFramework6\Add-Migration Foo
EntityFramework6\Update-Database
or
EntityFrameworkCore\Add-Migration Foo
EntityFrameworkCore\Update-Database
Note that for EF6 fans, at time of writing, the migration tools port to Core isn't quite up to scratch yet, as per here.
Similarly, if you have multiple DbContexts even in the same framework version (EfCore vs Ef6 on Core), you'll need to specify the name of the specific DbContext that you are trying to target, e.g.
EntityFramework6\Add-Migration Foo -Context BarDbContext
EntityFramework6\Add-Migration Baz -Context FooDbContext
Perhaps you have at least two projects in your solution each one using either version of EF. By issuing "Manage NuGet packages for solution..." you can verify if this is the case. Then, maybe you'd need to sacrifice the one using EF 6.x. After that you'll need to restart VS, maybe some caching prevents removing the package completely when you uninstall it.
EDIT: .. or you may live well with both of them, but read carefully the message and follow what it says...
If both Entity Framework Core and Entity Framework 6 are installed, and you wanna use The Entity Framework 6.
Use this command in the Package Manager Console:
'EntityFramework\Update-Database'.
No needs to delete or change anything. Just add **EntityFramework** before your EF6 Commands.
To add a migration for EF7 use the dotnet command: dotnet ef migrations add Initial
To update your database use the dotnet command: dotnet ef database update
Just...
Edit your project (Project -> right button -> edit) and DELETE EntityFramewok Line
DELETE a line like
<PackageReference Include="Entityframework" Version="6.2.0" />
And use ONLY EntityFramework Core
I am trying compile mobile applications using 'ant' task as shown below
<target name="target-name">
<app-builder
worklightserverhost="localhost:9080"
applicationFolder="/home/apps/CLSDashboard"
environments="desktopbrowser,ipad"
nativeProjectPrefix=""
outputFolder="bin/" />
</target>
But it errors as shown below
BUILD FAILED
/home/clsapp/build_apps_and_adapters.xml:14: Failed building application: You are trying to build iOS environment, but the required attribute 'nativeProjectPrefix' is missing. Add 'nativeProjectPrefix' attribute with project name as value to <app-builder> task and re-run the script.
Though I can understand the error how to avoid building apps for other environments (or) otherwise I want to compile 'apps' only for 'desktop' and 'iPad'
Since you're attempting to build an iOS environment (iPad...) you also need to specify a value for the nativeProjectPrefix property. The value should be the name of the project.
Per the documentation:
The nativeProjectPrefix attribute is mandatory when you build iOS
applications
I am developing a wix installer. This wix installer installs a 3rdparty msipackage.
I want my wix bootstrapper project to install this msipackage no matter what version that should already exist on the users pc. This means that if the same version(or a newer version) exists it should overwrite that installation.
I install my msipackage like this:
<MsiPackage Id="InstacalFull" Name="Measurement Computing InstaCal" Vital="yes" Compressed="yes" SourceFile="../Suite.SetupBootstrapper/3rdparty/Instacal/InstaCal.msi">
Does anyone have any ideas on how to achieve this?
Use InstallCondition="1"
This will install it every time
http://wixtoolset.org/documentation/manual/v3/xsd/wix/msipackage.html
InstallCondition
String
A condition to evaluate before installing the package. The package will only be installed if the condition evaluates to true. If the condition evaluates to false and the bundle is being installed, repaired, or modified, the package will be uninstalled.
I know this one is old, but since I came across this issue, maybe it would help someone, too.
In my case Repair was enough, so although technically it wasn't reinstall, practically Repair = Reinstall.
I needed to reinstall URLrewrite, because it could get broken when IIS Windows feature was disabled.
What you need it to add custom handler for PlanPackageBegin in you custom BootstrapperApplication class, for example:
CustomBootstrapperApplication.Model.Bootstrapper.PlanPackageBegin += this.PlanPackageBegin;
...........
private void PlanPackageBegin(object sender, PlanPackageBeginEventArgs e)
{
if (e.PackageId.ToLower().Contains("urlrewrite"))
{
if (CustomBootstrapperApplication.Model.Command.Action != LaunchAction.Uninstall && e.State == RequestState.Present)
{
CustomBootstrapperApplication.Model.Engine.Log(LogLevel.Verbose, string.Format("{0} is installed, forcing Repair", e.PackageId));
e.State = RequestState.Repair;
}
}
_packageList.Add(e.PackageId, e.State);
}
And in the the Bundle:
<!-- Note: this Id is used in PlanPackageBegin -->
<MsiPackage Id='urlrewrite2X64' Vital='no'
Permanent='yes'
SourceFile="rewrite_amd64.msi"
DownloadUrl="http://example.com/rewrite_amd64.msi"
DisplayInternalUI="no"
Visible="yes"
InstallCondition="VersionNT64"/>
You can force uninstallation of previous MSI during upgrade by something like this inside PlanPackageBegin:
if (LaunchAction.Uninstall == CustomBootstrapperApplication.Model.Command.Action && (CustomBootstrapperApplication.Model.Command.Relation == RelationType.Upgrade))
{
e.State = RequestState.None;
}
I am looking to write a wrapper for the MSBuild C# api. I have the build all working fine, but for some odd reason I'm struggling to get Nuget package restore to run even when I pass in the parameters.
I am running this in a service that runs as NETWORK SERVICE
The command ""..\.nuget\nuget.exe" install "C:\BuildTemp\application1\packages.config" -source "" -RequireConsent -o "..\packages"" exited with code 1.
Am I passing them in correctly?
var pc = new ProjectCollection();
var buildProperties = new Dictionary<string, string>
{
{"Configuration", "Release"},
{"Platform", "Any CPU"},
{"OutputPath", _outputPath},
{"EnableNuGetPackageRestore", "true"}
};
var buildParameters = new BuildParameters(pc);
var buildRequest = new BuildRequestData("C:\myapplication.csproj",
buildProperties,
null,
new[] { "Clean", "Rebuild" },
null);
UPDATE: this appears to work in some environments and not others. Why would this be?
So I tested out this command on my local machine:
.\.nuget\NuGet.exe install Akavache\packages.config -source "" -RequireConsent -o packages
and I get an error:
Invalid URI: The format of the URI could not be determined.
which I believe is related to this bit:
-source ""
As I can drop that value and have it run again without an error.
Which begs the question, where are the package sources defined?
Inside the NuGet.targets file there's a section like this:
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>
So I propose that when you say it works "in some environments and not others" that you don't have a config file at %APPDATA%\NuGet\NuGet.Config for the service account.
Can you try changing this section in your Nuget.targets file in source control to be:
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<PackageSource Include="https://nuget.org/api/v2/" />
</ItemGroup>
And see if that resolves your issues in the other environments?